mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-11 23:19:05 +00:00
Remove 'total' & 'traffic' in dataflow database table
This commit is contained in:
@@ -15,7 +15,7 @@ class NodeAuthController extends Controller
|
||||
// 节点授权列表
|
||||
public function index()
|
||||
{
|
||||
return view('admin.node.auth', ['authorizations' => NodeAuth::with('node')->orderBy('node_id')->paginate()->appends(request('page'))]);
|
||||
return view('admin.node.auth', ['authorizations' => NodeAuth::with('node:id,name,type,server,ip')->has('node')->orderBy('node_id')->paginate()->appends(request('page'))]);
|
||||
}
|
||||
|
||||
// 添加节点授权
|
||||
|
||||
@@ -28,7 +28,7 @@ class NodeController extends Controller
|
||||
{
|
||||
$status = $request->input('status');
|
||||
|
||||
$query = Node::whereNull('relay_node_id')->with('onlineLogs', 'dailyDataFlows', 'heartbeats', 'childNodes');
|
||||
$query = Node::whereNull('relay_node_id')->with(['onlineLogs', 'dailyDataFlows:node_id,u,d', 'heartbeats', 'childNodes']);
|
||||
|
||||
if (isset($status)) {
|
||||
$query->whereStatus($status);
|
||||
@@ -36,9 +36,8 @@ class NodeController extends Controller
|
||||
|
||||
$nodeList = $query->orderByDesc('sort')->orderBy('id')->paginate(15)->appends($request->except('page'));
|
||||
foreach ($nodeList as $node) {
|
||||
$online_log = $node->onlineLogs->where('log_time', '>=', strtotime('-5 minutes'))->sortBy('log_time')->first(); // 在线人数
|
||||
$node->online_users = $online_log->online_user ?? 0;
|
||||
$node->transfer = formatBytes($node->dailyDataFlows->sum('total')); // 已产生流量
|
||||
$node->online_users = $node->onlineLogs->where('log_time', '>=', strtotime('-5 minutes'))->sortBy('log_time')->first()?->online_user; // 在线人数
|
||||
$node->transfer = formatBytes($node->dailyDataFlows->sum('u') + $node->dailyDataFlows->sum('d')); // 已产生流量
|
||||
$node_info = $node->heartbeats->where('log_time', '>=', strtotime(config('tasks.recently_heartbeat')))->sortBy('log_time')->first(); // 近期负载
|
||||
$node->isOnline = $node_info !== null && ! empty($node_info->load);
|
||||
$node->load = $node_info->load ?? false;
|
||||
|
||||
@@ -71,7 +71,7 @@ class ReportController extends Controller
|
||||
if (isset($user)) {
|
||||
// 用户当前小时在各线路消耗流量
|
||||
$data['currentHourlyFlow'] = $user->dataFlowLogs()
|
||||
->where('log_time', '>=', strtotime(date('Y-m-d H:00')))
|
||||
->where('log_time', '>=', now()->startOfHour()->timestamp)
|
||||
->groupBy('node_id')
|
||||
->selectRaw('node_id, sum(u + d) as total')
|
||||
->get()->toArray();
|
||||
@@ -79,8 +79,8 @@ class ReportController extends Controller
|
||||
// 用户今天各小时在各线路消耗流量
|
||||
$data['hours'] = range(0, 23);
|
||||
$data['hourlyFlow'] = $user->hourlyDataFlows()->whereNotNull('node_id')
|
||||
->where('created_at', '>=', date('Y-m-d H:i:s', strtotime('-1 days')))
|
||||
->selectRaw('node_id, (DATE_FORMAT(user_hourly_data_flow.created_at, "%k")) as date, total')
|
||||
->whereDate('created_at', now())
|
||||
->selectRaw('node_id, (DATE_FORMAT(user_hourly_data_flow.created_at, "%k")) as date, u + d as total')
|
||||
->get()->transform(function ($item) {
|
||||
return [
|
||||
'node_id' => $item->node_id,
|
||||
@@ -93,8 +93,7 @@ class ReportController extends Controller
|
||||
$data['days'] = range(1, date('j'));
|
||||
$data['dailyFlow'] = $user->dailyDataFlows()->whereNotNull('node_id')
|
||||
->whereMonth('created_at', date('n'))
|
||||
->where('total', '>', 6000000)
|
||||
->selectRaw('node_id, (DATE_FORMAT(user_daily_data_flow.created_at, "%e")) as date, total')
|
||||
->selectRaw('node_id, (DATE_FORMAT(user_daily_data_flow.created_at, "%e")) as date, u + d as total')
|
||||
->get()->transform(function ($item) {
|
||||
return [
|
||||
'node_id' => $item->node_id,
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Models\Label;
|
||||
use App\Models\Level;
|
||||
use App\Models\Node;
|
||||
use App\Models\NodeDailyDataFlow;
|
||||
use App\Models\NodeHourlyDataFlow;
|
||||
use App\Models\Order;
|
||||
use App\Models\ReferralApply;
|
||||
use App\Models\ReferralLog;
|
||||
@@ -28,9 +29,9 @@ class AdminController extends Controller
|
||||
public function index()
|
||||
{
|
||||
$past = strtotime('-'.sysConfig('expire_days').' days');
|
||||
$dailyTrafficUsage = NodeHourlyDataFlow::whereDate('created_at', date('Y-m-d'))->sum(\DB::raw('u + d'));
|
||||
|
||||
return view('admin.index', [
|
||||
'expireDays' => sysConfig('expire_days'),
|
||||
'totalUserCount' => User::count(), // 总用户数
|
||||
'todayRegister' => User::whereDate('created_at', date('Y-m-d'))->count(), // 今日注册用户
|
||||
'enableUserCount' => User::whereEnable(1)->count(), // 有效用户数
|
||||
@@ -42,10 +43,10 @@ class AdminController extends Controller
|
||||
'largeTrafficUserCount' => User::whereRaw('(u + d)/transfer_enable >= 0.9')->where('status', '<>', -1)->count(), // 流量使用超过90%的用户
|
||||
'flowAbnormalUserCount' => count((new UserHourlyDataFlow)->trafficAbnormal()), // 1小时内流量异常用户
|
||||
'nodeCount' => Node::count(),
|
||||
'unnormalNodeCount' => Node::whereStatus(0)->count(),
|
||||
'flowCount' => formatBytes(NodeDailyDataFlow::where('created_at', '>=', date('Y-m-d', strtotime('-30 days')))->sum('total')),
|
||||
'todayFlowCount' => formatBytes(NodeDailyDataFlow::where('created_at', '>=', date('Y-m-d'))->sum('total')),
|
||||
'totalFlowCount' => formatBytes(NodeDailyDataFlow::sum('total')),
|
||||
'abnormalNodeCount' => Node::whereStatus(0)->count(),
|
||||
'monthlyTrafficUsage' => formatBytes(NodeDailyDataFlow::whereMonth('created_at', date('n'))->sum(\DB::raw('u + d'))),
|
||||
'dailyTrafficUsage' => $dailyTrafficUsage ? formatBytes($dailyTrafficUsage) : 0,
|
||||
'totalTrafficUsage' => formatBytes(NodeDailyDataFlow::sum(\DB::raw('u + d'))),
|
||||
'totalCredit' => User::where('credit', '<>', 0)->sum('credit') / 100,
|
||||
'totalWaitRefAmount' => ReferralLog::whereIn('status', [0, 1])->sum('commission') / 100,
|
||||
'todayWaitRefAmount' => ReferralLog::whereIn('status', [0, 1])->whereDate('created_at', date('Y-m-d'))->sum('commission') / 100,
|
||||
|
||||
Reference in New Issue
Block a user