mirror of
https://github.com/status-im/fathom.git
synced 2025-03-01 11:30:28 +00:00
- allows showing an hourly chart on the 'today' view - fixes timezone issues when in 'today' view #134 - increases size of stats tables by factor 24, but that should be less of an issue after dbcadcd73772258f2d2fd781673e559d5ed74dba
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
// URL: /api/stats/site
|
|
func (api *API) GetSiteStatsHandler(w http.ResponseWriter, r *http.Request) error {
|
|
params := GetRequestParams(r)
|
|
result, err := api.database.GetAggregatedSiteStats(params.SiteID, params.StartDate, params.EndDate)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return respond(w, http.StatusOK, envelope{Data: result})
|
|
}
|
|
|
|
// URL: /api/stats/site/realtime
|
|
func (api *API) GetSiteStatsRealtimeHandler(w http.ResponseWriter, r *http.Request) error {
|
|
params := GetRequestParams(r)
|
|
result, err := api.database.GetRealtimeVisitorCount(params.SiteID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return respond(w, http.StatusOK, envelope{Data: result})
|
|
}
|
|
|
|
// URL: /api/stats/site/groupby/day
|
|
func (api *API) GetSiteStatsPerDayHandler(w http.ResponseWriter, r *http.Request) error {
|
|
params := GetRequestParams(r)
|
|
result, err := api.database.GetSiteStatsPerDay(params.SiteID, params.StartDate, params.EndDate)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return respond(w, http.StatusOK, envelope{Data: result})
|
|
}
|