diff --git a/app/Http/Controllers/DiscordTestController.php b/app/Http/Controllers/DiscordTestController.php index 86b9b906..9c91120c 100644 --- a/app/Http/Controllers/DiscordTestController.php +++ b/app/Http/Controllers/DiscordTestController.php @@ -6,6 +6,7 @@ use App\Services\DiscordClient; use Illuminate\Support\Facades\Http; use App\Jobs\DiscordTrainingWeeklyUpdates; +use App\Jobs\ProcessShanwickController; class DiscordTestController extends Controller { @@ -38,6 +39,20 @@ public function Job() ]); } + public function Job2() + { + // Dispatch the job + $job = ProcessShanwickController::dispatch(); + + // Call the handle method directly to get the result synchronously + $result = $job->handle(); + + return response()->json([ + 'message' => 'Job executed successfully', + 'data' => $result, + ]); + } + public function SendEmbed() { //New Applicant in Instructor Channel diff --git a/app/Jobs/DiscordTrainingWeeklyUpdates.php b/app/Jobs/DiscordTrainingWeeklyUpdates.php index 2b4b222a..ec73fe48 100644 --- a/app/Jobs/DiscordTrainingWeeklyUpdates.php +++ b/app/Jobs/DiscordTrainingWeeklyUpdates.php @@ -203,11 +203,12 @@ public function handle() // Terminate Training { - $term_training++; - $terminate_names["names"][] = $thread['name']; $s = Student::where('created_at', '<=', Carbon::now()->subDays(60))->where('user_id', $cid)->first(); if($s != null && $s->hasLabel('Awaiting Exam')){ + $term_training++; + $terminate_names["names"][] = $thread['name']; + //Make as not current $s->current = false; diff --git a/routes/web.php b/routes/web.php index a788ed22..8f80732d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -76,6 +76,7 @@ // Discord shortcut Route::get('/discord', [DiscordController::class, 'joinShortcut']); Route::get('/discord/function-test', [DiscordTestController::class, 'Job']); +Route::get('/discord/function-test2', [DiscordTestController::class, 'Job2']); Route::post('/discord/bot-webhook', [DiscordController::class, 'handelDiscordCommand']); // Public news articles