diff --git a/app/Console/Commands/SendKeypressStatsCommand.php b/app/Console/Commands/SendKeypressStatsCommand.php new file mode 100644 index 0000000..dcf79eb --- /dev/null +++ b/app/Console/Commands/SendKeypressStatsCommand.php @@ -0,0 +1,32 @@ +execute(); + $this->info('Done!'); + } +} diff --git a/app/Services/Commands/SendKeypressStatsService.php b/app/Services/Commands/SendKeypressStatsService.php index 9f13190..a9f249b 100644 --- a/app/Services/Commands/SendKeypressStatsService.php +++ b/app/Services/Commands/SendKeypressStatsService.php @@ -47,12 +47,23 @@ class SendKeypressStatsService $query = "SELECT {$this->provinceId} AS province_id, '{$this->provinceName}' AS province_name, - date, - COUNT(CASE WHEN message_quality=1 THEN 1 END) AS message_quality_ok, - COUNT(CASE WHEN message_quality=0 THEN 1 END) AS message_quality_nok, - COUNT(CASE WHEN format_quality=1 THEN 1 END) AS message_format_ok, - COUNT(CASE WHEN format_quality=0 THEN 1 END) AS message_format_nok, - FROM system_messages GROUP BY date ORDER BY date DESC LIMIT 5"; + DATE(cdate) AS date, + COUNT(CASE WHEN (ctype=-1 AND channel=0) THEN 1 END) AS total, + COUNT(CASE WHEN (ctype=1 AND channel=0) THEN 1 END) AS key1, + COUNT(CASE WHEN (ctype=2 AND channel=0) THEN 1 END) AS key2, + COUNT(CASE WHEN (ctype=3 AND channel=0) THEN 1 END) AS key3, + COUNT(CASE WHEN (ctype=4 AND channel=0) THEN 1 END) AS key4, + COUNT(CASE WHEN (ctype=5 AND channel=0) THEN 1 END) AS key5, + COUNT(CASE WHEN (ctype=6 AND channel=0) THEN 1 END) AS key6, + COUNT(CASE WHEN (ctype=9 AND channel=0) THEN 1 END) AS key9, + COUNT(CASE WHEN (ctype=1 AND channel=4) THEN 1 END) AS key4_1, + COUNT(CASE WHEN (ctype=2 AND channel=4) THEN 1 END) AS key4_2, + COUNT(CASE WHEN (ctype=1 AND channel=5) THEN 1 END) AS key5_1, + COUNT(CASE WHEN (ctype=2 AND channel=5) THEN 1 END) AS key5_2, + COUNT(CASE WHEN (ctype=1 AND channel=2) THEN 1 END) AS key2_1, + COUNT(CASE WHEN (ctype=2 AND channel=2) THEN 1 END) AS key2_2, + COUNT(CASE WHEN (ctype=3 AND channel=2) THEN 1 END) AS key2_3 + FROM report WHERE DATE(cdate)> DATE(NOW()- INTERVAL 3 day) GROUP BY date ORDER BY date DESC"; return DB::select($query); } diff --git a/routes/console.php b/routes/console.php index 3c9adf1..8243f79 100644 --- a/routes/console.php +++ b/routes/console.php @@ -6,3 +6,8 @@ use Illuminate\Support\Facades\Artisan; Artisan::command('inspire', function () { $this->comment(Inspiring::quote()); })->purpose('Display an inspiring quote'); + +Schedule::command('report:send-call-stats')->everyTwoMinutes(); +Schedule::command('report:send-system-message-stats')->everyThreeMinutes(); +Schedule::command('report:send-keypress-stats')->everyFourMinutes(); +Schedule::command('report:send-people-message-stats')->everyFiveMinutes();