fix(analyticsApi): fixed last_30_days_data (5)
Build and Push Docker image / build-and-push (push) Successful in 2m10s
Details
Build and Push Docker image / build-and-push (push) Successful in 2m10s
Details
This commit is contained in:
parent
21908ecfb4
commit
b0b92f0e64
|
@ -145,15 +145,20 @@ func initPageViewCount(app *pocketbase.PocketBase, e *core.ServeEvent) {
|
||||||
(
|
(
|
||||||
SELECT json_group_array(
|
SELECT json_group_array(
|
||||||
json_object(
|
json_object(
|
||||||
'date', strftime('%Y-%m-%d', created),
|
'date', date,
|
||||||
'count', COUNT(id)
|
'count', daily_count
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
strftime('%Y-%m-%d', created) AS date,
|
||||||
|
COUNT(id) AS daily_count
|
||||||
FROM analyticsPageViews
|
FROM analyticsPageViews
|
||||||
WHERE
|
WHERE
|
||||||
path = view.path AND
|
path = view.path AND
|
||||||
created >= datetime('now', '-30 days')
|
created >= datetime('now', '-30 days')
|
||||||
GROUP BY strftime('%Y-%m-%d', created)
|
GROUP BY date
|
||||||
|
) AS daily_data
|
||||||
) AS last_30_days_data
|
) AS last_30_days_data
|
||||||
FROM
|
FROM
|
||||||
analyticsPageViews view
|
analyticsPageViews view
|
||||||
|
@ -192,14 +197,17 @@ func initPageViewCount(app *pocketbase.PocketBase, e *core.ServeEvent) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the final JSON response
|
// Final response structure
|
||||||
return c.JSON(200, map[string]interface{}{
|
response := map[string]interface{}{
|
||||||
"page": page,
|
"page": page,
|
||||||
"perPage": perPage,
|
"perPage": perPage,
|
||||||
"totalItems": totalItems,
|
"totalItems": totalItems,
|
||||||
"totalPages": totalPages,
|
"totalPages": totalPages,
|
||||||
"items": items,
|
"items": items,
|
||||||
})
|
}
|
||||||
|
|
||||||
|
// Return the final JSON response
|
||||||
|
return c.JSON(200, response)
|
||||||
}, apis.ActivityLogger(app))
|
}, apis.ActivityLogger(app))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue