fix(analyticsApi): startdate is now query param
Build and Push Docker image / build-and-push (push) Successful in 2m9s Details

This commit is contained in:
Valentin Kolb 2024-11-13 00:10:17 +01:00
parent 333443f271
commit 13d20a99e9
1 changed files with 2 additions and 10 deletions

View File

@ -23,23 +23,15 @@ import (
// "startDate": "start date in ISO 8601 format",
// }
func initSessionCount(app *pocketbase.PocketBase, e *core.ServeEvent) {
e.Router.GET("/api/analytics/sessionCounts", func(c echo.Context) error {
e.Router.GET("/api/analytics/count", func(c echo.Context) error {
// Check if user is in admin group
if err := ldapApi.UserIsInAdminGroup(app, c); err != nil {
return err
}
// Get data from request
data := struct {
StartDate string `json:"startDate"`
}{}
if err := c.Bind(&data); err != nil {
return apis.NewBadRequestError("Failed to read request data", err)
}
// Parse the start date
startDate, err := time.Parse(time.RFC3339, data.StartDate)
startDate, err := time.Parse(time.RFC3339, c.QueryParam("startDate"))
if err != nil {
return apis.NewBadRequestError("Invalid start date format, expected ISO 8601", err)
}