Skip to content

Commit

Permalink
Merge pull request #343 from czqoocavatsim/JoshuaBranch
Browse files Browse the repository at this point in the history
Email Introduction, RosterInactivity and MonthlyBreakdown Changes
  • Loading branch information
JoshuaMicallefYBSU authored Sep 1, 2024
2 parents 9c96423 + a93e017 commit 0f1730d
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 34 deletions.
39 changes: 20 additions & 19 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Jobs\ProcessSoloCertExpiryWarnings;
use App\Jobs\ProcessShanwickController;
use App\Jobs\DiscordTrainingWeeklyUpdates;
use App\Jobs\ProcessMonthlyBreakdown;
use App\Jobs\UpdateDiscordUserRoles;
use App\Jobs\DiscordAccountCheck;
use App\Models\Roster\RosterMember;
Expand Down Expand Up @@ -42,7 +43,25 @@ protected function schedule(Schedule $schedule)
$schedule->job(new ProcessSessionLogging())->everyMinute();

//Inactivity checks
$schedule->job(new ProcessRosterInactivity())->dailyAt('14:05');
$schedule->job(new ProcessRosterInactivity())->daily();

// Monthly Statistics Breakdown
$schedule->job(new ProcessMonthlyBreakdown())->monthlyOn(1, '00:40');

//Solo cert expiry warning
// $schedule->job(new ProcessSoloCertExpiryWarnings())->daily();

// Shanwick Controller Roster Update
$schedule->job(new ProcessShanwickController())->daily();

//Training/OTS session reminders
$schedule->job(new ProcessSessionReminders())->daily();

// Check Training Threads Status (Once per week)
$schedule->job(new DiscordTrainingWeeklyUpdates())->weeklyOn(6, '6:00');

// Check If Account is Linked
$schedule->job(new DiscordAccountCheck)->weeklyOn(5, '0:30');

//CRONS FOR INACTIVITY EMAILS 2 weeks
// $schedule->call(function () {
Expand Down Expand Up @@ -77,24 +96,6 @@ protected function schedule(Schedule $schedule)
// $discord = new DiscordClient();
// $discord->sendMessage(753086414811562014, 'Sent '.$count.' one-week warning inactivity emails');
// })->cron('00 00 23 MAR,JUN,SEP,DEC *'); // 1 week before end of quarter*/

// Monthly Statistics Breakdown
$schedule->job(new ProcessShanwickController())->monthlyOn(1, '00:00');

//Solo cert expiry warning
// $schedule->job(new ProcessSoloCertExpiryWarnings())->daily();

// Shanwick Controller Roster Update
$schedule->job(new ProcessShanwickController())->daily();

//Training/OTS session reminders
$schedule->job(new ProcessSessionReminders())->daily();

// Check Training Threads Status (Once per week)
$schedule->job(new DiscordTrainingWeeklyUpdates())->weeklyOn(6, '6:00');

// Check If Account is Linked
$schedule->job(new DiscordAccountCheck)->weeklyOn(5, '0:30');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Training/ApplicationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public function adminAcceptApplication($reference_id, Request $request)
$discord->assignRole($student->user->discord_user_id, 482824058141016075);

//Create Instructor Thread
$discord->createTrainingThread($student->user->id, '<@'.$student->user->discord_user_id.'>');
$discord->createTrainingThread($student->user->fullName('FLC'), '<@'.$student->user->discord_user_id.'>');

// Notify Senior Team that the application was accepted.
$discord->sendMessageWithEmbed(config('app.env') == 'local' ? intval(config('services.discord.web_logs')) : intval(config('services.discord.applications')), 'Accepted Applicant', $student->user->fullName('FLC').' has just been accepted.', 'error');
Expand Down
6 changes: 3 additions & 3 deletions app/Jobs/ProcessMonthlyBreakdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public function handle()
$total_hours += $roster->monthly_hours;
}

// Compose the message
$message = 'It is the beginning of a new month, so here are some wonderful stats for ' . Carbon::now()->subMonth()->format('F, Y') . "\n\n";

$message .= "**__Total Controller Hours__**\n";
$message .= "- " . $total_hours . " hours\n";

$message .= "\n**__Top 3 Controllers__**\n";

foreach($top_3 as $t) {
if($t->user->discord_user_id === null){
$message .= "- " . $t->user->fullName('FLC') . " - ".$t->monthly_hours."\n";
Expand All @@ -59,7 +59,6 @@ public function handle()
}

$message .= "\n**__New Certified Controllers__**\n";

foreach($new_controllers as $nc) {
if($nc->controller->discord_user_id === null){
$message .= "- " . $nc->controller->fullName('FLC') . "\n";
Expand All @@ -70,8 +69,9 @@ public function handle()

$message .= "\nWell done to everyone for your contributions to Gander Oceanic over the last Month! Enjoy ".Carbon::now()->format('F, Y');

// Send the Announcement
$discord = new DiscordClient();
$discord->sendMessageWithEmbed('488265136696459292', 'Gander Oceanic Operations Breakdown - '.Carbon::now()->subMonth()->format('F, Y'), $message);
$discord->sendMessageWithEmbed(env('DISCORD_ANNOUNCEMENTS'), 'Gander Oceanic Operations Breakdown - '.Carbon::now()->subMonth()->format('F, Y'), $message);

foreach($roster_member as $roster){
$roster->monthly_hours = 0.0;
Expand Down
6 changes: 4 additions & 2 deletions app/Jobs/ProcessRosterInactivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Notification;
use App\Notifications\Roster\RosterStatusChanged;
use App\Notifications\Roster\RemovedFromRoster;
use App\Notifications\Network\TwoMonthInactivityReminder;
use App\Notifications\Network\OneMonthInactivityReminder;
use App\Notifications\Network\OneWeekInactivityReminder;
use App\Notifications\Network\ControllerTerminated;
use App\Services\DiscordClient;

class ProcessRosterInactivity implements ShouldQueue
Expand Down
71 changes: 71 additions & 0 deletions app/Notifications/Network/ControllerTerminated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace App\Notifications\Network;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class ControllerTerminated extends Notification implements ShouldQueue
{
use Queueable;
protected $rosterMember, $cycle;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($rosterMember, $cycle)
{
$this->rosterMember = $rosterMember;
$this->cycle = $cycle;
}

/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}

/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage())
->greeting("Hi {$this->rosterMember->user->fullName('FLC')}")
->line('**Controller Certification Expired**')
->line('According to our records, you have not controlled **1 hour** online controlling on EGGX, CZQO or NAT within the last 12 months.')
->line('This email is notification that your Gander Oceanic Certification has now expired.')
->line('In order to reattain this certification, please apply via the Gander Oceanic Website.')
->line("Please don’t hesitate to contact us should you have any concerns.")
->line('*You received this email as there is important information in regard to your status with Gander Oceanic.*')
->salutation('Sent automatically through ActivityBot.')
->subject('[NOTICE] Controller Certification Expired');
}

/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
*
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
70 changes: 70 additions & 0 deletions app/Notifications/Network/OneMonthInactivityReminder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace App\Notifications\Network;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class OneMonthInactivityReminder extends Notification implements ShouldQueue
{
use Queueable;
protected $rosterMember, $cycle;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($rosterMember, $cycle)
{
$this->rosterMember = $rosterMember;
$this->cycle = $cycle;
}

/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}

/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage())
->greeting("Hi {$this->rosterMember->user->fullName('FLC')}")
->line('**One Month - Activity Reminder**')
->line('According to our records, you have not yet fulfilled our currency requirement. You require **1 hour** online controlling on EGGX, CZQO or NAT in a 12 Month Period.')
->line('This email serves only as a reminder in case you may have forgotten.')
->line("Please don’t hesitate to contact us should you have any concerns.")
->line('*You received this email as there is important information in regard to your status with Gander Oceanic.*')
->salutation('Sent automatically through ActivityBot.')
->subject('[NOTICE] One Month To Fulfil Activity Requirement');
}

/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
*
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
8 changes: 4 additions & 4 deletions app/Notifications/Network/OneWeekInactivityReminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public function toMail($notifiable)
{
return (new MailMessage())
->greeting("Hi {$this->rosterMember->user->fullName('FLC')}")
->line('**One Week Left - Activity Reminder**')
->line('According to our records, you have not yet fulfilled our currency requirement. You require **6 hours** online controlling on Gander or Shanwick or Bandbox by the end of the quarter, otherwise you will be marked inactive.')
->line('There is one week remaining in the current quarter, so this email serves only as a reminder in case you may have forgotten.')
->line("Please don’t hesitate to contact us should you have any concerns, or if you need us to make an accommodation. We're here to help!")
->line('**Activity Reminder - One Week till Uncertified**')
->line('According to our records, you have not yet fulfilled our currency requirement. You require **1 hour** online controlling on EGGX, CZQO or NAT in a 12 Month Period.')
->line('There is one week remaining in this requirement, so this email serves only as a reminder in case you may have forgotten.')
->line("Please don’t hesitate to contact us should you have any concerns.")
->line('*You received this email as there is important information in regard to your status with Gander Oceanic.*')
->salutation('Sent automatically through ActivityBot.')
->subject('[NOTICE] One Week To Fulfil Activity Requirement');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class TwoWeekInactivityReminder extends Notification implements ShouldQueue
class TwoMonthInactivityReminder extends Notification implements ShouldQueue
{
use Queueable;
protected $rosterMember, $cycle;
Expand Down Expand Up @@ -46,12 +46,12 @@ public function toMail($notifiable)
return (new MailMessage())
->greeting("Hi {$this->rosterMember->user->fullName('FLC')}")
->line('**Two Weeks Left - Activity Reminder**')
->line('According to our records, you have not yet fulfilled our currency requirement. You require **6 hours** online controlling on Gander or Shanwick or Bandbox by the end of the quarter, otherwise you will be marked inactive.')
->line('There are two weeks remaining in the current quarter, so this email serves only as a reminder in case you may have forgotten.')
->line("Please don’t hesitate to contact us should you have any concerns, or if you need us to make an accommodation. We're here to help!")
->line('According to our records, you have not yet fulfilled our currency requirement. You require **1 hour** online controlling on EGGX, CZQO or NAT in a 12 Month Period.')
->line('This email serves only as a reminder in case you may have forgotten.')
->line("Please don’t hesitate to contact us should you have any concerns.")
->line('*You received this email as there is important information in regard to your status with Gander Oceanic.*')
->salutation('Sent automatically through ActivityBot.')
->subject('[NOTICE] Two Weeks To Fulfil Activity Requirement');
->subject('[NOTICE] Two Months To Fulfil Activity Requirement');
}

/**
Expand Down

0 comments on commit 0f1730d

Please sign in to comment.