update: log api

This commit is contained in:
v2board
2023-05-24 01:08:13 +08:00
parent 4dc6d29076
commit 3752bed0d6
8 changed files with 203 additions and 66 deletions

View File

@ -36,11 +36,13 @@ class StatController extends Controller
->get()
->makeHidden(['record_at', 'created_at', 'updated_at', 'id', 'record_type'])
->toArray();
} else {
$statisticalService = new StatisticalService();
return [
'data' => $statisticalService->generateStatData()
];
}
$statisticalService = new StatisticalService();
$stats = array_merge($stats ?? [], [$statisticalService->generateStatData()]);
$stats = array_reduce($stats, function($carry, $item) {
foreach($item as $key => $value) {
if(isset($carry[$key]) && $carry[$key]) {
@ -60,9 +62,9 @@ class StatController extends Controller
public function getStatRecord(Request $request)
{
$request->validate([
'type' => 'required|in:order_total,commission_total,register_count',
'type' => 'required|in:paid_total,commission_total,register_count',
'start_at' => '',
'end_at'
'end_at' => ''
]);
$statisticalService = new StatisticalService();
@ -73,6 +75,23 @@ class StatController extends Controller
];
}
public function getRanking(Request $request)
{
$request->validate([
'type' => 'required|in:server_traffic_rank,user_consumption_rank,invite_rank',
'start_at' => '',
'end_at' => '',
'limit' => 'nullable|integer'
]);
$statisticalService = new StatisticalService();
$statisticalService->setStartAt($request->input('start_at'));
$statisticalService->setEndAt($request->input('end_at'));
return [
'data' => $statisticalService->getRanking($request->input('type'), $request->input('limit') ?? 20)
];
}
public function getOverride(Request $request)
{
return [