add report for keypress
This commit is contained in:
32
app/Console/Commands/SendKeypressStatsCommand.php
Normal file
32
app/Console/Commands/SendKeypressStatsCommand.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\Commands\SendKeypressStatsService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendKeypressStatsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'report:send-keypress-stats';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'gather all keypress stats report and send them to the center';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(SendKeypressStatsService $service)
|
||||
{
|
||||
$service->execute();
|
||||
$this->info('Done!');
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user