Combine data with node_id in api output, so its all still "one day", and fits vanilla xboard behaviour

This commit is contained in:
socksprox
2025-11-29 14:04:37 +01:00
parent 1ebf86b510
commit 9ca8da045c
2 changed files with 32 additions and 4 deletions
@@ -14,9 +14,20 @@ class StatController extends Controller
public function getTrafficLog(Request $request)
{
$startDate = now()->startOfMonth()->timestamp;
// Aggregate per-node data back to per-day format for backward compatibility
$records = StatUser::query()
->select([
'user_id',
'server_rate',
'record_at',
'record_type',
DB::raw('SUM(u) as u'),
DB::raw('SUM(d) as d'),
])
->where('user_id', $request->user()->id)
->where('record_at', '>=', $startDate)
->groupBy(['user_id', 'server_rate', 'record_at', 'record_type'])
->orderBy('record_at', 'DESC')
->get();