From 13d20a99e907e0413716c67056c162ea1d5a8ecc Mon Sep 17 00:00:00 2001 From: valentinkolb Date: Wed, 13 Nov 2024 00:10:17 +0100 Subject: [PATCH] fix(analyticsApi): startdate is now query param --- analyticsApi/main.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/analyticsApi/main.go b/analyticsApi/main.go index 012bb62..8b077fc 100644 --- a/analyticsApi/main.go +++ b/analyticsApi/main.go @@ -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) }