From f1c86973c9b80db1f56d5ba3ec28d149b9b38a61 Mon Sep 17 00:00:00 2001 From: krateng Date: Mon, 1 Jan 2024 15:46:49 +0100 Subject: [PATCH] Fix incomplete scrobble results with associated artists --- maloja/database/sqldb.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/maloja/database/sqldb.py b/maloja/database/sqldb.py index 555e094..daaae0c 100644 --- a/maloja/database/sqldb.py +++ b/maloja/database/sqldb.py @@ -863,19 +863,24 @@ def get_scrobbles_of_artist(artist,since=None,to=None,resolve_references=True,li op = op.order_by(sql.desc('timestamp')) else: op = op.order_by(sql.asc('timestamp')) - if limit: + if limit and associated: + # if we count associated we cant limit here because we remove stuff later! op = op.limit(limit) result = dbconn.execute(op).all() # remove duplicates (multiple associated artists in the song, e.g. Irene & Seulgi being both counted as Red Velvet) # distinct on doesn't seem to exist in sqlite - seen = set() - filtered_result = [] - for row in result: - if row.timestamp not in seen: - filtered_result.append(row) - seen.add(row.timestamp) - result = filtered_result + if associated: + seen = set() + filtered_result = [] + for row in result: + if row.timestamp not in seen: + filtered_result.append(row) + seen.add(row.timestamp) + result = filtered_result + if limit: + result = result[:limit] + if resolve_references: