2018-12-04 10:48:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace BeyondCode\LaravelWebSockets\Console;
|
|
|
|
|
|
2020-08-18 18:22:29 +00:00
|
|
|
use BeyondCode\LaravelWebSockets\Statistics\Drivers\StatisticsDriver;
|
2018-12-04 10:48:07 +00:00
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
|
|
class CleanStatistics extends Command
|
|
|
|
|
{
|
2020-08-18 17:21:22 +00:00
|
|
|
/**
|
|
|
|
|
* The name and signature of the console command.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2018-12-04 10:48:07 +00:00
|
|
|
protected $signature = 'websockets:clean
|
2020-08-18 17:21:22 +00:00
|
|
|
{appId? : (optional) The app id that will be cleaned.}
|
|
|
|
|
';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The console command description.
|
|
|
|
|
*
|
|
|
|
|
* @var string|null
|
|
|
|
|
*/
|
2018-12-04 10:48:07 +00:00
|
|
|
protected $description = 'Clean up old statistics from the websocket log.';
|
|
|
|
|
|
2020-08-18 17:21:22 +00:00
|
|
|
/**
|
|
|
|
|
* Run the command.
|
|
|
|
|
*
|
2020-08-18 18:22:29 +00:00
|
|
|
* @param \BeyondCode\LaravelWebSockets\Statistics\Drivers\StatisticsDriver $driver
|
2020-08-18 17:21:22 +00:00
|
|
|
* @return void
|
|
|
|
|
*/
|
2020-08-18 18:22:29 +00:00
|
|
|
public function handle(StatisticsDriver $driver)
|
2018-12-04 10:48:07 +00:00
|
|
|
{
|
|
|
|
|
$this->comment('Cleaning WebSocket Statistics...');
|
|
|
|
|
|
2020-08-18 18:22:29 +00:00
|
|
|
$amountDeleted = $driver::delete($this->argument('appId'));
|
2018-12-04 10:48:07 +00:00
|
|
|
|
|
|
|
|
$this->info("Deleted {$amountDeleted} record(s) from the WebSocket statistics.");
|
|
|
|
|
}
|
2018-12-04 21:22:33 +00:00
|
|
|
}
|