feat: Implement Statistics API with 8 endpoints under /api/v1/statistics/
- Add statistics.sql with 8 SQL queries for play count statistics - Generate repository code via sqlc - Add backend/statistics.go with business logic - Add server/statistics_handler.go with Echo handlers - Register protected routes under /api/v1/statistics/ with token auth - Endpoints: games/most-played, games/least-played, games/never-played, games/last-played, games/oldest-played, songs/most-played, songs/least-played, summary Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -122,10 +122,38 @@ func (s *Server) RegisterRoutes() http.Handler {
|
||||
// Create token auth middleware with pool access
|
||||
tokenAuthMiddleware := middleware.TokenAuthMiddleware(s.db.Pool)
|
||||
|
||||
// Protected group with token authentication - will be used by VGMQ and Statistics API
|
||||
_ = apiV1.Group("", tokenAuthMiddleware)
|
||||
// Protected group with token authentication
|
||||
protectedV1 := apiV1.Group("", tokenAuthMiddleware)
|
||||
|
||||
// Note: Future protected endpoints (VGMQ, Statistics) will be added here
|
||||
// Statistics API endpoints (protected by token auth)
|
||||
statistics := s.statisticsHandler
|
||||
protectedV1.GET("/statistics/games/most-played", func(c *echo.Context) error {
|
||||
return statistics.GetMostPlayedGames(c)
|
||||
})
|
||||
protectedV1.GET("/statistics/games/least-played", func(c *echo.Context) error {
|
||||
return statistics.GetLeastPlayedGames(c)
|
||||
})
|
||||
protectedV1.GET("/statistics/games/never-played", func(c *echo.Context) error {
|
||||
return statistics.GetNeverPlayedGames(c)
|
||||
})
|
||||
protectedV1.GET("/statistics/games/last-played", func(c *echo.Context) error {
|
||||
return statistics.GetLastPlayedGames(c)
|
||||
})
|
||||
protectedV1.GET("/statistics/games/oldest-played", func(c *echo.Context) error {
|
||||
return statistics.GetOldestPlayedGames(c)
|
||||
})
|
||||
protectedV1.GET("/statistics/songs/most-played", func(c *echo.Context) error {
|
||||
return statistics.GetMostPlayedSongs(c)
|
||||
})
|
||||
protectedV1.GET("/statistics/songs/least-played", func(c *echo.Context) error {
|
||||
return statistics.GetLeastPlayedSongs(c)
|
||||
})
|
||||
protectedV1.GET("/statistics/summary", func(c *echo.Context) error {
|
||||
return statistics.GetStatisticsSummary(c)
|
||||
})
|
||||
|
||||
// Future: VGMQ endpoints will be added to protectedV1 group
|
||||
_ = protectedV1 // Use the variable to avoid unused variable error
|
||||
|
||||
routes := e.Router().Routes()
|
||||
sort.Slice(routes, func(i, j int) bool {
|
||||
|
||||
Reference in New Issue
Block a user