diff --git a/app/Console/Commands/V2boardCache.php b/app/Console/Commands/V2boardCache.php deleted file mode 100644 index 835ac03d..00000000 --- a/app/Console/Commands/V2boardCache.php +++ /dev/null @@ -1,68 +0,0 @@ -where('updated_at', '>=', time() - 3600) - ->groupBy('server_id') - ->get(); - foreach ($serverLogs as $serverLog) { - $data = [ - 'server_id' => $serverLog->server_id, - 'u' => $serverLog->u, - 'd' => $serverLog->d, - 'online' => $serverLog->online - ]; -// ServerStat::create($data); - } - } -} diff --git a/app/Console/Commands/StatServer.php b/app/Console/Commands/V2boardStatistics.php similarity index 76% rename from app/Console/Commands/StatServer.php rename to app/Console/Commands/V2boardStatistics.php index 1992bf24..9693244b 100644 --- a/app/Console/Commands/StatServer.php +++ b/app/Console/Commands/V2boardStatistics.php @@ -7,21 +7,21 @@ use Illuminate\Console\Command; use App\Models\ServerLog; use Illuminate\Support\Facades\DB; -class StatServer extends Command +class V2BoardStatistics extends Command { /** * The name and signature of the console command. * * @var string */ - protected $signature = 'stat:server'; + protected $signature = 'v2board:statistics'; /** * The console command description. * * @var string */ - protected $description = '统计节点数据'; + protected $description = '统计任务'; /** * Create a new command instance. @@ -39,15 +39,20 @@ class StatServer extends Command * @return mixed */ public function handle() + { + $this->statServer(); + } + + private function statServer() { $endAt = strtotime(date('Y-m-d')); $startAt = strtotime('-1 day', $endAt); $statistics = ServerLog::select([ - 'server_id', - 'method as server_type', - DB::raw("sum(u) as u"), - DB::raw("sum(d) as d"), - ]) + 'server_id', + 'method as server_type', + DB::raw("sum(u) as u"), + DB::raw("sum(d) as d"), + ]) ->where('log_at', '>=', $startAt) ->where('log_at', '<', $endAt) ->groupBy('server_id', 'method') diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 0452f611..b8f845df 100755 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -25,7 +25,7 @@ class Kernel extends ConsoleKernel protected function schedule(Schedule $schedule) { // v2board - $schedule->command('v2board:cache')->hourly(); + $schedule->command('v2board:statistics')->daily(); // check $schedule->command('check:order')->everyMinute(); $schedule->command('check:commission')->everyMinute();