From 284500e760c4041ba92d008bd5e5c7dbc770231a Mon Sep 17 00:00:00 2001 From: Voten641 Date: Mon, 22 Jun 2026 20:28:20 +0200 Subject: [PATCH] fix(subsonic): address review issues in getSongHistory endpoint. --- persistence/scrobble_repository.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/persistence/scrobble_repository.go b/persistence/scrobble_repository.go index b84379671..1a2f40837 100644 --- a/persistence/scrobble_repository.go +++ b/persistence/scrobble_repository.go @@ -43,6 +43,12 @@ func (h *dbHistoryEntry) PostScan() error { } func (r *scrobbleRepository) GetHistory(offset, count int) ([]model.HistoryEntry, error) { + if offset < 0 { + offset = 0 + } + if count <= 0 { + count = 50 + } userID := loggedUser(r.ctx).ID sq := Select("m.*", "s.submission_time"). From(r.tableName+" s"). @@ -59,16 +65,13 @@ func (r *scrobbleRepository) GetHistory(offset, count int) ([]model.HistoryEntry entries := make([]model.HistoryEntry, 0, len(rows)) for i := range rows { - entry := model.HistoryEntry{ + if rows[i].MediaFile == nil { + continue + } + entries = append(entries, model.HistoryEntry{ MediaFile: *rows[i].MediaFile, PlayedAt: time.Unix(rows[i].SubmissionTime, 0), - } - var err error - entry.Participants, err = r.getParticipants(rows[i].MediaFile) - if err != nil { - return nil, err - } - entries = append(entries, entry) + }) } return entries, nil }