fix(analyticsApi): fixed last_30_days_data (2)
Build and Push Docker image / build-and-push (push) Successful in 3m45s Details

This commit is contained in:
Valentin Kolb 2024-11-13 01:42:30 +01:00
parent f8e15cdd47
commit db0e73b7b9
1 changed files with 8 additions and 13 deletions

View File

@ -135,23 +135,18 @@ func initPageViewCount(app *pocketbase.PocketBase, e *core.ServeEvent) {
FROM analyticsPageViews FROM analyticsPageViews
WHERE path = view.path AND created >= {:startDate} WHERE path = view.path AND created >= {:startDate}
) AS count, ) AS count,
( (
SELECT json_group_array( SELECT json_group_array(
json_object( json_object(
'date', date, 'date', strftime('%Y-%m-%d', created),
'count', daily_count 'count', COUNT(id)
) )
) )
FROM ( FROM analyticsPageViews
SELECT WHERE
strftime('%Y-%m-%dT%H:%M:%SZ', created) AS date, path = view.path AND
COUNT(id) AS daily_count created >= datetime('now', '-30 days')
FROM analyticsPageViews GROUP BY strftime('%Y-%m-%d', created)
WHERE
path = view.path AND
created >= datetime('now', '-30 days')
GROUP BY date
) AS daily_data
) AS last_30_days_data ) AS last_30_days_data
FROM FROM
analyticsPageViews view analyticsPageViews view