mirror of
https://github.com/v2board/v2board.git
synced 2025-02-15 01:40:28 +08:00
update: statistics
This commit is contained in:
parent
7e5e696c70
commit
bcea2e7a54
@ -1,68 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use App\Utils\CacheKey;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use App\Models\ServerLog;
|
|
||||||
use App\Models\ServerStat;
|
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class V2boardCache extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'v2board:cache';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = '缓存任务';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private function cacheServerStat()
|
|
||||||
{
|
|
||||||
$serverLogs = ServerLog::select(
|
|
||||||
'server_id',
|
|
||||||
DB::raw("sum(u) as u"),
|
|
||||||
DB::raw("sum(d) as d"),
|
|
||||||
DB::raw("count(*) as online")
|
|
||||||
)
|
|
||||||
->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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,21 +7,21 @@ use Illuminate\Console\Command;
|
|||||||
use App\Models\ServerLog;
|
use App\Models\ServerLog;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class StatServer extends Command
|
class V2BoardStatistics extends Command
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The name and signature of the console command.
|
* The name and signature of the console command.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'stat:server';
|
protected $signature = 'v2board:statistics';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $description = '统计节点数据';
|
protected $description = '统计任务';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new command instance.
|
* Create a new command instance.
|
||||||
@ -39,6 +39,11 @@ class StatServer extends Command
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
|
{
|
||||||
|
$this->statServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function statServer()
|
||||||
{
|
{
|
||||||
$endAt = strtotime(date('Y-m-d'));
|
$endAt = strtotime(date('Y-m-d'));
|
||||||
$startAt = strtotime('-1 day', $endAt);
|
$startAt = strtotime('-1 day', $endAt);
|
@ -25,7 +25,7 @@ class Kernel extends ConsoleKernel
|
|||||||
protected function schedule(Schedule $schedule)
|
protected function schedule(Schedule $schedule)
|
||||||
{
|
{
|
||||||
// v2board
|
// v2board
|
||||||
$schedule->command('v2board:cache')->hourly();
|
$schedule->command('v2board:statistics')->daily();
|
||||||
// check
|
// check
|
||||||
$schedule->command('check:order')->everyMinute();
|
$schedule->command('check:order')->everyMinute();
|
||||||
$schedule->command('check:commission')->everyMinute();
|
$schedule->command('check:commission')->everyMinute();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user