From 69e11c1bc1bee302ded3302dd3194df7efadd239 Mon Sep 17 00:00:00 2001 From: JoshuaMicallefYBSU <91457812+JoshuaMicallefYBSU@users.noreply.github.com> Date: Mon, 19 Aug 2024 03:22:25 +1000 Subject: [PATCH] Fix AvailabilityUpdate Fix Availability Update not checking Status Label. --- app/Console/Kernel.php | 2 +- app/Jobs/DiscordTrainingUpdates.php | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 55f86929..fabc49b5 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -106,7 +106,7 @@ protected function schedule(Schedule $schedule) $schedule->job(new ProcessSessionReminders())->daily(); // Check Training Threads Status (Once per week) - $schedule->job(new DiscordTrainingUpdates())->weeklyOn(7, '17:00'); + $schedule->job(new DiscordTrainingUpdates())->weeklyOn(7, '17:25'); // Discord role updating //$schedule->job(new UpdateDiscordUserRoles)->twiceDaily(6, 18); diff --git a/app/Jobs/DiscordTrainingUpdates.php b/app/Jobs/DiscordTrainingUpdates.php index cd92a60a..aa27f90f 100644 --- a/app/Jobs/DiscordTrainingUpdates.php +++ b/app/Jobs/DiscordTrainingUpdates.php @@ -97,18 +97,20 @@ public function handle() $cid = null; } + $student = Student::where('user_id', $cid)->first(); + // Check Lable is 'In Progress' or 'Ready For Pick-Up' + if($student->hasLabel('In Progress') || $student->hasLabel('Ready For Pick-Up')){ - // Check Sessions Upcoming - $student = Student::where('user_id', $cid)->first(); - $upcoming_sessions = TrainingSession::where('student_id', $student->id)->whereBetween('scheduled_time', [Carbon::now(), Carbon::now()->addDays(7)])->first(); - - if($upcoming_sessions == null){ - // There is no sessions within the next week - $counter++; //Add 1 to the $counter variable + // Check Sessions Upcoming + $upcoming_sessions = TrainingSession::where('student_id', $student->id)->whereBetween('scheduled_time', [Carbon::now(), Carbon::now()->addDays(7)])->first(); - // SendEmbed to ask student to send availability - $discord->sendEmbedInTrainingThread($cid, "Your Availability", 'Hello, <@'.$student->user->discord_user_id.'> + if($upcoming_sessions == null){ + // There is no sessions within the next week + $counter++; //Add 1 to the $counter variable + + // SendEmbed to ask student to send availability + $discord->sendEmbedInTrainingThread($cid, "Your Availability", 'Hello, <@'.$student->user->discord_user_id.'> Please provide your availability for the next 7-14 days. Please ensure to tag the `@Instructor` role with all times you are available. Please provide these times in Zulu Format. @@ -117,6 +119,7 @@ public function handle() *If you have done this in the past few days, please disregard this message.*'); } } + } // Tell the log chat $discord->sendMessageWithEmbed(env('DISCORD_WEB_LOGS'), 'AUTO: Training Thread Availability Requests',$counter. ' Training Threads have been messaged asking for their weekly availability. This is only completed if a student has no scheduled session within the next 7 days.');