mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-24 12:07:28 +08:00
fix: resolve PHPStan static analysis warnings
This commit is contained in:
@@ -2,12 +2,10 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\StatServer;
|
||||
use App\Models\StatUser;
|
||||
use App\Services\StatisticalService;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Stat;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class XboardStatistics extends Command
|
||||
{
|
||||
@@ -50,67 +48,6 @@ class XboardStatistics extends Command
|
||||
info('统计任务执行完毕。耗时:' . (microtime(true) - $startAt) / 1000);
|
||||
}
|
||||
|
||||
private function statServer()
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$createdAt = time();
|
||||
$recordAt = strtotime('-1 day', strtotime(date('Y-m-d')));
|
||||
$statService = new StatisticalService();
|
||||
$statService->setStartAt($recordAt);
|
||||
$stats = $statService->getStatServer();
|
||||
foreach ($stats as $stat) {
|
||||
if (!StatServer::insert([
|
||||
'server_id' => $stat['server_id'],
|
||||
'server_type' => $stat['server_type'],
|
||||
'u' => $stat['u'],
|
||||
'd' => $stat['d'],
|
||||
'created_at' => $createdAt,
|
||||
'updated_at' => $createdAt,
|
||||
'record_type' => 'd',
|
||||
'record_at' => $recordAt
|
||||
])) {
|
||||
throw new \Exception('stat server fail');
|
||||
}
|
||||
}
|
||||
DB::commit();
|
||||
$statService->clearStatServer();
|
||||
} catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
\Log::error($e->getMessage(), ['exception' => $e]);
|
||||
}
|
||||
}
|
||||
|
||||
private function statUser()
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$createdAt = time();
|
||||
$recordAt = strtotime('-1 day', strtotime(date('Y-m-d')));
|
||||
$statService = new StatisticalService();
|
||||
$statService->setStartAt($recordAt);
|
||||
$stats = $statService->getStatUser();
|
||||
foreach ($stats as $stat) {
|
||||
if (!StatUser::insert([
|
||||
'user_id' => $stat['user_id'],
|
||||
'u' => $stat['u'],
|
||||
'd' => $stat['d'],
|
||||
'server_rate' => $stat['server_rate'],
|
||||
'created_at' => $createdAt,
|
||||
'updated_at' => $createdAt,
|
||||
'record_type' => 'd',
|
||||
'record_at' => $recordAt
|
||||
])) {
|
||||
throw new \Exception('stat user fail');
|
||||
}
|
||||
}
|
||||
DB::commit();
|
||||
$statService->clearStatUser();
|
||||
} catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
\Log::error($e->getMessage(), ['exception' => $e]);
|
||||
}
|
||||
}
|
||||
|
||||
private function stat()
|
||||
{
|
||||
@@ -132,7 +69,7 @@ class XboardStatistics extends Command
|
||||
}
|
||||
Stat::create($data);
|
||||
} catch (\Exception $e) {
|
||||
\Log::error($e->getMessage(), ['exception' => $e]);
|
||||
Log::error($e->getMessage(), ['exception' => $e]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user