Add GET /api/v1/statistics/soundtracks with every soundtrack and its songs
The other soundtrack statistics are capped at 100, so a client that shows every soundtrack (the MusicPlayer statistics tab) had no way to get them all. This one has no limit and is sorted by name.
This commit is contained in:
1 parent
fc7d787014
commit
080bacae80
9 files changed
+147
-1
No files matched your search
@@ -59,7 +59,8 @@ type soundtrackRow interface {
|
||||
repository.GetMostPlayedSoundtracksWithSongsRow |
|
||||
repository.GetLeastPlayedSoundtracksWithSongsRow |
|
||||
repository.GetLastPlayedSoundtracksRow |
|
||||
repository.GetOldestPlayedSoundtracksRow
|
||||
repository.GetOldestPlayedSoundtracksRow |
|
||||
repository.GetAllSoundtracksWithSongsRow
|
||||
}
|
||||
|
||||
func toSoundtracks[R soundtrackRow](rows []R, err error) ([]SoundtrackWithSongs, error) {
|
||||
@@ -106,6 +107,11 @@ func parseSongs(data []byte) []SongInfoForStats {
|
||||
return songs
|
||||
}
|
||||
|
||||
// AllSoundtracks returns every soundtrack with its songs, sorted by name
|
||||
func (s *StatisticsService) AllSoundtracks(ctx context.Context) ([]SoundtrackWithSongs, error) {
|
||||
return toSoundtracks(s.q.GetAllSoundtracksWithSongs(ctx))
|
||||
}
|
||||
|
||||
// MostPlayedSoundtracks returns the top N most played soundtracks with their songs
|
||||
func (s *StatisticsService) MostPlayedSoundtracks(ctx context.Context, limit int32) ([]SoundtrackWithSongs, error) {
|
||||
return toSoundtracks(s.q.GetMostPlayedSoundtracksWithSongs(ctx, limit))
|
||||
|
||||
Reference in new issue
Block a user