File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -192,26 +192,36 @@ public function autoCleanup()
192
192
{
193
193
if ($ this ->auto_cleanup_num > 0 ) {
194
194
if ($ this ->auto_cleanup_type === 'results ' ) {
195
- $ oldest_id = self :: results ()
195
+ $ oldest_id = $ this -> results ()
196
196
->orderBy ('ran_at ' , 'desc ' )
197
197
->limit ($ this ->auto_cleanup_num )
198
198
->get ()
199
199
->min ('id ' );
200
200
do {
201
- $ rowsDeleted = self :: results ()
201
+ $ rowsToDelete = $ this -> results ()
202
202
->where ('id ' , '< ' , $ oldest_id )
203
- ->limit (500 )
203
+ ->limit (50 )
204
204
->getQuery ()
205
+ ->select ('id ' )
206
+ ->pluck ('id ' );
207
+
208
+ Result::query ()
209
+ ->whereIn ('id ' , $ rowsToDelete )
205
210
->delete ();
206
- } while ($ rowsDeleted > 0 );
211
+ } while ($ rowsToDelete > 0 );
207
212
} else {
208
213
do {
209
- $ rowsDeleted = self :: results ()
214
+ $ rowsToDelete = $ this -> results ()
210
215
->where ('ran_at ' , '< ' , Carbon::now ()->subDays ($ this ->auto_cleanup_num - 1 ))
211
- ->limit (500 )
216
+ ->limit (50 )
212
217
->getQuery ()
218
+ ->select ('id ' )
219
+ ->pluck ('id ' );
220
+
221
+ Result::query ()
222
+ ->whereIn ('id ' , $ rowsToDelete )
213
223
->delete ();
214
- } while ($ rowsDeleted > 0 );
224
+ } while ($ rowsToDelete > 0 );
215
225
}
216
226
}
217
227
}
You can’t perform that action at this time.
0 commit comments