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()
192192 {
193193 if ($ this ->auto_cleanup_num > 0 ) {
194194 if ($ this ->auto_cleanup_type === 'results ' ) {
195- $ oldest_id = self :: results ()
195+ $ oldest_id = $ this -> results ()
196196 ->orderBy ('ran_at ' , 'desc ' )
197197 ->limit ($ this ->auto_cleanup_num )
198198 ->get ()
199199 ->min ('id ' );
200200 do {
201- $ rowsDeleted = self :: results ()
201+ $ rowsToDelete = $ this -> results ()
202202 ->where ('id ' , '< ' , $ oldest_id )
203- ->limit (500 )
203+ ->limit (50 )
204204 ->getQuery ()
205+ ->select ('id ' )
206+ ->pluck ('id ' );
207+
208+ Result::query ()
209+ ->whereIn ('id ' , $ rowsToDelete )
205210 ->delete ();
206- } while ($ rowsDeleted > 0 );
211+ } while ($ rowsToDelete > 0 );
207212 } else {
208213 do {
209- $ rowsDeleted = self :: results ()
214+ $ rowsToDelete = $ this -> results ()
210215 ->where ('ran_at ' , '< ' , Carbon::now ()->subDays ($ this ->auto_cleanup_num - 1 ))
211- ->limit (500 )
216+ ->limit (50 )
212217 ->getQuery ()
218+ ->select ('id ' )
219+ ->pluck ('id ' );
220+
221+ Result::query ()
222+ ->whereIn ('id ' , $ rowsToDelete )
213223 ->delete ();
214- } while ($ rowsDeleted > 0 );
224+ } while ($ rowsToDelete > 0 );
215225 }
216226 }
217227 }
You can’t perform that action at this time.
0 commit comments