Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
SendExecutiveReport
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 handle
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace App\Console\Commands;
4
5use App\Http\Controllers\Notifications;
6use Illuminate\Console\Command;
7use Illuminate\Http\Request;
8use Illuminate\Support\Facades\Log;
9
10class SendExecutiveReport extends Command
11{
12    /**
13     * The name and signature of the console command.
14     *
15     * @var string
16     */
17    protected $signature = 'send:executive-report';
18
19    /**
20     * The console command description.
21     *
22     * @var string
23     */
24    protected $description = 'Send email executive report';
25
26    /**
27     * Execute the console command.
28     */
29    public function handle(): void
30    {
31        // FIRE-1025: heartbeat logs so a missed Saturday dispatch is
32        // observable. Pre-fix, the only sink was the catch-Exception
33        // path, so when the dispatch never reached the SendGrid block
34        // (e.g. the box was CPU-starved by another runaway cron) there
35        // was no trace at all in cron_send_executive_report.log. Pair
36        // these markers with the count from `tbl_notification_logs
37        // WHERE total_executive_report = 1 AND created_at >= …` to
38        // verify a run actually completed.
39        Log::channel('cron_send_executive_report')->info('send:executive-report STARTED');
40
41        try {
42
43            $notifications = new Notifications;
44
45            $r = new Request([
46                'processed_by' => 'System',
47                'User-ID' => 1,
48            ]);
49
50            $notifications->send_executive($r);
51
52            Log::channel('cron_send_executive_report')->info('send:executive-report FINISHED');
53
54        } catch (\Exception $e) {
55            Log::channel('cron_send_executive_report')->error('send:executive-report FAILED: '.$e->getMessage());
56        }
57
58    }
59}