File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -192,26 +192,38 @@ 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
+
212
+ } while ($ rowsToDelete > 0 );
207
213
} else {
208
214
do {
209
- $ rowsDeleted = self :: results ()
215
+ $ rowsToDelete = $ this -> results ()
210
216
->where ('ran_at ' , '< ' , Carbon::now ()->subDays ($ this ->auto_cleanup_num - 1 ))
211
- ->limit (500 )
217
+ ->limit (50 )
212
218
->getQuery ()
219
+ ->select ('id ' )
220
+ ->pluck ('id ' );
221
+
222
+ Result::query ()
223
+ ->whereIn ('id ' , $ rowsToDelete )
213
224
->delete ();
214
- } while ($ rowsDeleted > 0 );
225
+
226
+ } while ($ rowsToDelete > 0 );
215
227
}
216
228
}
217
229
}
You can’t perform that action at this time.
0 commit comments