高考版优化
审核模式优化
This commit is contained in:
@@ -133,13 +133,18 @@ class Analytics extends BaseController
|
||||
}
|
||||
$days = min(180, max(1, (int) Request::param('days', 30)));
|
||||
$since = date('Y-m-d H:i:s', time() - $days * 86400);
|
||||
$page = max(1, (int) Request::param('page', 1));
|
||||
$pageSize = min(100, max(1, (int) Request::param('pageSize', 20)));
|
||||
$offset = ($page - 1) * $pageSize;
|
||||
|
||||
try {
|
||||
$rows = Db::name('analytics_events')
|
||||
$baseQ = Db::name('analytics_events')
|
||||
->where('userId', $userId)
|
||||
->where('createdAt', '>=', $since)
|
||||
->where('createdAt', '>=', $since);
|
||||
$total = (int) (clone $baseQ)->count();
|
||||
$rows = (clone $baseQ)
|
||||
->order('id', 'desc')
|
||||
->limit(200)
|
||||
->limit($offset, $pageSize)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
@@ -156,10 +161,12 @@ class Analytics extends BaseController
|
||||
$rows = AnalyticsEventLabels::withCn($rows);
|
||||
|
||||
return success([
|
||||
'userId' => $userId,
|
||||
'days' => $days,
|
||||
'list' => $rows,
|
||||
'total' => count($rows),
|
||||
'userId' => $userId,
|
||||
'days' => $days,
|
||||
'list' => $rows,
|
||||
'total' => $total,
|
||||
'page' => $page,
|
||||
'pageSize' => $pageSize,
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
return success([
|
||||
@@ -167,6 +174,8 @@ class Analytics extends BaseController
|
||||
'days' => $days,
|
||||
'list' => [],
|
||||
'total' => 0,
|
||||
'page' => $page,
|
||||
'pageSize' => $pageSize,
|
||||
'tableMissing' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user