mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-22 02:07:23 +08:00
perf: 优化流量消费相关代码性能,解决流量纪录与已用流量有概率不一致的问题
This commit is contained in:
@@ -110,13 +110,11 @@ class StatController extends Controller
|
||||
$recordAt = strtotime(date('Y-m-d'));
|
||||
$statService = new StatisticalService();
|
||||
$statService->setStartAt($recordAt);
|
||||
$statService->setServerStats();
|
||||
$stats = $statService->getStatServer();
|
||||
$statistics = collect($stats)->map(function ($item){
|
||||
$item['total'] = $item['u'] + $item['d'];
|
||||
return $item;
|
||||
})->sortByDesc('total')->values()->all();
|
||||
// return json_encode($statistics);
|
||||
foreach ($statistics as $k => $v) {
|
||||
foreach ($servers[$v['server_type']] as $server) {
|
||||
if ($server['id'] === $v['server_id']) {
|
||||
@@ -190,7 +188,6 @@ class StatController extends Controller
|
||||
$recordAt = strtotime(date('Y-m-d'));
|
||||
$statService = new StatisticalService();
|
||||
$statService->setStartAt($recordAt);
|
||||
$statService->setUserStats();
|
||||
$todayTraffics = $statService->getStatUserByUserID($request->input('user_id'));
|
||||
if (($current == 1) && count($todayTraffics) > 0) {
|
||||
foreach ($todayTraffics as $todayTraffic){
|
||||
|
||||
Reference in New Issue
Block a user