Skip to content

Commit

Permalink
Merge pull request #300 from czqoocavatsim/JoshuaBranch
Browse files Browse the repository at this point in the history
Fix AvailabilityUpdate
  • Loading branch information
JoshuaMicallefYBSU authored Aug 18, 2024
2 parents bc9a3f3 + 69e11c1 commit 4ae3539
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 12 additions & 9 deletions app/Jobs/DiscordTrainingUpdates.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.');
Expand Down

0 comments on commit 4ae3539

Please sign in to comment.