From 2a52cacddabba23966bc94dc1c87860ed4339514 Mon Sep 17 00:00:00 2001 From: JoshuaMicallefYBSU <91457812+JoshuaMicallefYBSU@users.noreply.github.com> Date: Mon, 19 Aug 2024 06:01:53 +1000 Subject: [PATCH] TestAgain --- app/Console/Kernel.php | 2 +- app/Jobs/DiscordTrainingUpdates.php | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 0e2ba958..f34e5fd0 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, '19:28'); + $schedule->job(new DiscordTrainingUpdates())->weeklyOn(7, '20:03'); // Discord role updating //$schedule->job(new UpdateDiscordUserRoles)->twiceDaily(6, 18); diff --git a/app/Jobs/DiscordTrainingUpdates.php b/app/Jobs/DiscordTrainingUpdates.php index 01482afd..37c5c883 100644 --- a/app/Jobs/DiscordTrainingUpdates.php +++ b/app/Jobs/DiscordTrainingUpdates.php @@ -91,6 +91,8 @@ public function handle() $response = $discord->getClient()->get('guilds/'.env('DISCORD_GUILD_ID').'/threads/active'); $results2 = json_decode($response->getBody(), true); + // dd($results2); + foreach ($results2['threads'] as $thread) { // Get the ID of the Active Training Thread @@ -102,10 +104,10 @@ public function handle() // See if user is still a student if($cid !== null){ - $student = Student::whereCurrent(true)->where('user_id', $cid)->firstOrFail(); + $student = Student::whereCurrent(true)->where('user_id', $cid)->first(); - //Is student already ready for assessment? - if ($student && ($student->hasLabel('In Progress') !== false || $student->hasLabel('Ready For Pick-Up') !== false)) { + //Is the Applied Tag = "In Progress" or "Ready For Pick-Up"? + if ($student && ($thread['applied_tags'] == "1271846369510035627" || $thread['applied_tags'] == "1271847420631978107")) { // Check Sessions Upcoming $upcoming_sessions = TrainingSession::where('student_id', $student->id)->whereBetween('scheduled_time', [Carbon::now(), Carbon::now()->addDays(7)])->first();