From 6c3992e781633875a44042bdc5664b8fe80b2ffb Mon Sep 17 00:00:00 2001 From: "B.Fatih KOZ" <74361521+FatihKoz@users.noreply.github.com> Date: Sat, 10 Apr 2021 02:15:22 +0300 Subject: [PATCH] Fix for Hourly Crons (#1127) * Fix for Hourly Cron We should be using whereTime instead of whereDate https://laravel.com/docs/8.x/queries#additional-where-clauses `The whereDate method may be used to compare a column's value against a date` * Fix for RemoveExpiredBids I used where to do check 'cause people may set 48 hours to remove a bid, thus neither whereDate nor whereTime will give a correct results. * Fix for DeletePireps I used where to do check 'cause people may set 48 hours to delete cancelled or rejected pireps, thus neither whereDate nor whereTime will give a correct results. --- app/Cron/Hourly/DeletePireps.php | 2 +- app/Cron/Hourly/RemoveExpiredBids.php | 2 +- app/Cron/Hourly/RemoveExpiredLiveFlights.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Cron/Hourly/DeletePireps.php b/app/Cron/Hourly/DeletePireps.php index 0ac449ff..8e7e21fc 100644 --- a/app/Cron/Hourly/DeletePireps.php +++ b/app/Cron/Hourly/DeletePireps.php @@ -38,7 +38,7 @@ class DeletePireps extends Listener protected function deletePireps(int $expire_time_hours, int $state) { $dt = Carbon::now()->subHours($expire_time_hours); - $pireps = Pirep::whereDate('created_at', '<', $dt)->where(['state' => $state])->get(); + $pireps = Pirep::where('created_at', '<', $dt)->where(['state' => $state])->get(); /** @var PirepService $pirepSvc */ $pirepSvc = app(PirepService::class); diff --git a/app/Cron/Hourly/RemoveExpiredBids.php b/app/Cron/Hourly/RemoveExpiredBids.php index ad1807e6..7d8f80fc 100644 --- a/app/Cron/Hourly/RemoveExpiredBids.php +++ b/app/Cron/Hourly/RemoveExpiredBids.php @@ -26,6 +26,6 @@ class RemoveExpiredBids extends Listener } $date = Carbon::now()->subHours(setting('bids.expire_time')); - Bid::whereDate('created_at', '<', $date)->delete(); + Bid::where('created_at', '<', $date)->delete(); } } diff --git a/app/Cron/Hourly/RemoveExpiredLiveFlights.php b/app/Cron/Hourly/RemoveExpiredLiveFlights.php index 22df9398..5aaf9cc9 100644 --- a/app/Cron/Hourly/RemoveExpiredLiveFlights.php +++ b/app/Cron/Hourly/RemoveExpiredLiveFlights.php @@ -27,7 +27,7 @@ class RemoveExpiredLiveFlights extends Listener } $date = Carbon::now()->subHours(setting('acars.live_time')); - Pirep::whereDate('updated_at', '<', $date) + Pirep::whereTime('updated_at', '<', $date) ->where('state', PirepState::IN_PROGRESS) ->delete(); }