mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-07 21:48:18 -08:00
feat: Rewind (#116)
* wip * chore: update counts to allow unix timeframe * feat: add db functions for counting new items * wip: endpoint working * wip * wip: initial ui done * add header, adjust ui * add time listened toggle * fix layout, year param * param fixes
This commit is contained in:
parent
c0a8c64243
commit
d4ac96f780
64 changed files with 2252 additions and 1055 deletions
|
|
@ -42,35 +42,35 @@ func StatsHandler(store db.DB) http.HandlerFunc {
|
|||
|
||||
l.Debug().Msgf("StatsHandler: Fetching statistics for period '%s'", period)
|
||||
|
||||
listens, err := store.CountListens(r.Context(), period)
|
||||
listens, err := store.CountListens(r.Context(), db.Timeframe{Period: period})
|
||||
if err != nil {
|
||||
l.Err(err).Msg("StatsHandler: Failed to fetch listen count")
|
||||
utils.WriteError(w, "failed to get listens: "+err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
tracks, err := store.CountTracks(r.Context(), period)
|
||||
tracks, err := store.CountTracks(r.Context(), db.Timeframe{Period: period})
|
||||
if err != nil {
|
||||
l.Err(err).Msg("StatsHandler: Failed to fetch track count")
|
||||
utils.WriteError(w, "failed to get tracks: "+err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
albums, err := store.CountAlbums(r.Context(), period)
|
||||
albums, err := store.CountAlbums(r.Context(), db.Timeframe{Period: period})
|
||||
if err != nil {
|
||||
l.Err(err).Msg("StatsHandler: Failed to fetch album count")
|
||||
utils.WriteError(w, "failed to get albums: "+err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
artists, err := store.CountArtists(r.Context(), period)
|
||||
artists, err := store.CountArtists(r.Context(), db.Timeframe{Period: period})
|
||||
if err != nil {
|
||||
l.Err(err).Msg("StatsHandler: Failed to fetch artist count")
|
||||
utils.WriteError(w, "failed to get artists: "+err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
timeListenedS, err := store.CountTimeListened(r.Context(), period)
|
||||
timeListenedS, err := store.CountTimeListened(r.Context(), db.Timeframe{Period: period})
|
||||
if err != nil {
|
||||
l.Err(err).Msg("StatsHandler: Failed to fetch time listened")
|
||||
utils.WriteError(w, "failed to get time listened: "+err.Error(), http.StatusInternalServerError)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue