This commit is contained in:
2023-11-24 20:49:19 +08:00
parent ca5219cb93
commit be14f5fdb1
65 changed files with 1991 additions and 2214 deletions

View File

@@ -29,17 +29,15 @@ protected function schedule(Schedule $schedule)
private function scheduleCategory(Schedule $schedule, $locale, $categoryName, $taskName)
{
$schedule->call(function () use ($locale, $categoryName) {
$category = Category::where('country_locale_slug', $locale)->where('name', $categoryName)->first();
if (!is_null($category))
{
$task = $category->country_locale_slug . "-" . $category->slug;
if (! is_null($category)) {
$task = $category->country_locale_slug.'-'.$category->slug;
$nextRun = DailyTaskSchedule::where('task', $task)->first();
if (!is_null($nextRun))
{
if (! is_null($nextRun)) {
$currentTime = now();
if ($currentTime->gte($nextRun->next_run_time)) {
@@ -57,11 +55,9 @@ private function scheduleCategory(Schedule $schedule, $locale, $categoryName, $t
$nextRun->next_run_time = now()->addMinutes(rand(1200, 1440));
$nextRun->save();
}
}
else
{
} else {
$nextRun = new DailyTaskSchedule;
$nextRun->task = $category->country_locale_slug . "-" . $category->slug;
$nextRun->task = $category->country_locale_slug.'-'.$category->slug;
$nextRun->next_run_time = now()->addMinutes(rand(0, 1440));
$nextRun->save();
}