diff --git a/src/Http/Controllers/Configuration/ScheduleController.php b/src/Http/Controllers/Configuration/ScheduleController.php index 64a9eb6b1..6aef76ebe 100644 --- a/src/Http/Controllers/Configuration/ScheduleController.php +++ b/src/Http/Controllers/Configuration/ScheduleController.php @@ -118,8 +118,11 @@ public function createSchedulingRule(Request $request) $rule->filter = $request->filters; $rule->save(); - RefreshToken::all()->each(function ($token) { - CharacterSchedulingRule::updateRefreshTokenSchedule($token); + // chunk this to avoid out-of-memory issues on large installs + RefreshToken::chunk(200, function ($tokens) { + foreach ($tokens as $token) { + CharacterSchedulingRule::updateRefreshTokenSchedule($token); + } }); return redirect()->back() @@ -134,8 +137,11 @@ public function deleteSchedulingRule(Request $request) CharacterSchedulingRule::destroy($request->rule_id); - RefreshToken::all()->each(function ($token) { - CharacterSchedulingRule::updateRefreshTokenSchedule($token); + // chunk this to avoid out-of-memory issues on large installs + RefreshToken::chunk(200, function ($tokens) { + foreach ($tokens as $token) { + CharacterSchedulingRule::updateRefreshTokenSchedule($token); + } }); return redirect()->back()->with('success', 'Successfully removed character scheduling rule!'); diff --git a/src/Models/CharacterSchedulingRule.php b/src/Models/CharacterSchedulingRule.php index 471a5f6f7..e903f5bd4 100644 --- a/src/Models/CharacterSchedulingRule.php +++ b/src/Models/CharacterSchedulingRule.php @@ -66,6 +66,7 @@ public static function updateRefreshTokenSchedule(RefreshToken $token): void if($schedule === null) { $schedule = new RefreshTokenSchedule(); $schedule->character_id = $token->character_id; + $schedule->last_update = now()->subYears(10); // Hopefully this is far enough in the past to mean never? } $schedule->update_interval = self::getCharacterSchedulingInterval($token->character);