mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Merge pull request #10847 from WayneHarris/3.x-fix-chunk-order-in-exports
fix(exports) update prepare csv job to account for order by
This commit is contained in:
@@ -102,15 +102,19 @@ class PrepareCsvExport implements ShouldQueue
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$baseQuery = $query->toBase();
|
||||
$sortDirection = $baseQuery->orders[0]['direction'] ?? 'asc';
|
||||
|
||||
$query->toBase()
|
||||
$baseQuery
|
||||
->select([$query->getModel()->getQualifiedKeyName()])
|
||||
->chunkById(
|
||||
->orderedChunkById(
|
||||
$this->chunkSize * 10,
|
||||
fn (Collection $records) => $dispatchRecords(
|
||||
Arr::pluck($records->all(), $keyName),
|
||||
),
|
||||
$keyName,
|
||||
descending: $sortDirection === 'desc',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user