@@ -54,17 +54,19 @@ public function getExportBatchProperty(): ?Batch
54
54
55
55
public function updateExportProgress (): void
56
56
{
57
- if (!is_null ($ this ->exportBatch )) {
58
- $ this ->batchFinished = $ this ->exportBatch ->finished ();
59
- $ this ->batchProgress = $ this ->exportBatch ->progress ();
60
- $ this ->batchErrors = $ this ->exportBatch ->hasFailures ();
57
+ if (is_null ($ this ->exportBatch )) {
58
+ return ;
59
+ }
61
60
62
- if ( $ this ->batchFinished ) {
63
- $ this ->batchExporting = false ;
64
- }
61
+ $ this -> batchFinished = $ this ->exportBatch -> finished ();
62
+ $ this ->batchProgress = $ this -> exportBatch -> progress () ;
63
+ $ this -> batchErrors = $ this -> exportBatch -> hasFailures ();
65
64
66
- $ this ->onBatchExecuting ($ this ->exportBatch );
65
+ if ($ this ->batchFinished ) {
66
+ $ this ->batchExporting = false ;
67
67
}
68
+
69
+ $ this ->onBatchExecuting ($ this ->exportBatch );
68
70
}
69
71
70
72
public function downloadExport (string $ file ): BinaryFileResponse
@@ -104,20 +106,22 @@ private function putQueuesToBus(string $exportableClass, string $fileExtension):
104
106
105
107
$ this ->exportedFiles = [];
106
108
$ filters = $ processDataSource ?->component?->filters ?? [];
109
+ $ filtered = $ processDataSource ?->component?->filtered ?? [];
107
110
$ queues = collect ([]);
108
- $ countQueue = $ this ->total > $ this ->getQueuesCount () ? $ this ->getQueuesCount () : 1 ;
109
- $ perPage = $ this ->total > $ countQueue ? ($ this ->total / $ countQueue ) : 1 ;
111
+ $ queueCount = $ this ->total > $ this ->getQueuesCount () ? $ this ->getQueuesCount () : 1 ;
112
+ $ perPage = $ this ->total > $ queueCount ? ($ this ->total / $ queueCount ) : 1 ;
110
113
$ offset = 0 ;
111
114
$ limit = $ perPage ;
112
115
113
- for ($ i = 1 ; $ i < ($ countQueue + 1 ); $ i ++) {
114
- $ fileName = ' powergrid- ' . Str::kebab (strval (data_get ($ this ->setUp , 'exportable.fileName ' ))) .
116
+ for ($ i = 1 ; $ i < ($ queueCount + 1 ); $ i ++) {
117
+ $ fileName = Str::kebab (strval (data_get ($ this ->setUp , 'exportable.fileName ' ))) .
115
118
'- ' . round (($ offset + 1 ), 2 ) .
116
119
'- ' . round ($ limit , 2 ) .
117
120
'- ' . $ this ->getId () .
118
121
'. ' . $ fileExtension ;
119
122
120
123
$ params = [
124
+ 'filtered ' => $ filtered ,
121
125
'exportableClass ' => $ exportableClass ,
122
126
'fileName ' => $ fileName ,
123
127
'offset ' => $ offset ,
@@ -164,15 +168,16 @@ public function prepareToExport(bool $selected = false): Eloquent\Collection|Sup
164
168
{
165
169
$ processDataSource = tap (ProcessDataSource::make ($ this ), fn ($ datasource ) => $ datasource ->get ());
166
170
167
- $ inClause = $ processDataSource ->component ->filtered ;
171
+ $ filtered = $ processDataSource ->component ->filtered ;
168
172
169
173
if ($ selected && filled ($ processDataSource ->component ->checkboxValues )) {
170
- $ inClause = $ processDataSource ->component ->checkboxValues ;
174
+ $ filtered = $ processDataSource ->component ->checkboxValues ;
171
175
}
172
176
173
177
if ($ processDataSource ->component ->datasource () instanceof Collection) {
174
- if ($ inClause ) {
175
- $ results = $ processDataSource ->get (isExport: true )->whereIn ($ this ->primaryKey , $ inClause );
178
+ if ($ filtered ) {
179
+ $ results = $ processDataSource ->get (isExport: true )
180
+ ->whereIn ($ this ->primaryKey , $ filtered );
176
181
177
182
return DataSourceBase::transform ($ results , $ this );
178
183
}
@@ -191,8 +196,8 @@ public function prepareToExport(bool $selected = false): Eloquent\Collection|Sup
191
196
->filterContains ()
192
197
->filter ()
193
198
)
194
- ->when ($ inClause , function ($ query , $ inClause ) use ($ processDataSource ) {
195
- return $ query ->whereIn ($ processDataSource ->component ->primaryKey , $ inClause );
199
+ ->when ($ filtered , function ($ query , $ filtered ) use ($ processDataSource ) {
200
+ return $ query ->whereIn ($ processDataSource ->component ->primaryKey , $ filtered );
196
201
})
197
202
->orderBy ($ sortField , $ processDataSource ->component ->sortDirection )
198
203
->get ();
@@ -241,10 +246,9 @@ private function export(string $exportType, bool $selected): BinaryFileResponse|
241
246
/** @var string $fileName */
242
247
$ fileName = data_get ($ this ->setUp , 'exportable.fileName ' );
243
248
$ exportable
244
- ->fileName ($ fileName ) /** @phpstan-ignore-next-line */
249
+ ->fileName ($ fileName )
245
250
->setData ($ columnsWithHiddenState , $ this ->prepareToExport ($ selected ));
246
251
247
- /** @phpstan-ignore-next-line */
248
252
return $ exportable ->download (
249
253
exportOptions: $ this ->setUp ['exportable ' ]
250
254
);
0 commit comments