mirror of
https://github.com/krateng/maloja.git
synced 2025-07-09 03:04:07 -04:00
Fix incomplete scrobble results with associated artists
This commit is contained in:
parent
1f1a65840c
commit
f1c86973c9
@ -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'))
|
op = op.order_by(sql.desc('timestamp'))
|
||||||
else:
|
else:
|
||||||
op = op.order_by(sql.asc('timestamp'))
|
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)
|
op = op.limit(limit)
|
||||||
result = dbconn.execute(op).all()
|
result = dbconn.execute(op).all()
|
||||||
|
|
||||||
# remove duplicates (multiple associated artists in the song, e.g. Irene & Seulgi being both counted as Red Velvet)
|
# 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
|
# distinct on doesn't seem to exist in sqlite
|
||||||
seen = set()
|
if associated:
|
||||||
filtered_result = []
|
seen = set()
|
||||||
for row in result:
|
filtered_result = []
|
||||||
if row.timestamp not in seen:
|
for row in result:
|
||||||
filtered_result.append(row)
|
if row.timestamp not in seen:
|
||||||
seen.add(row.timestamp)
|
filtered_result.append(row)
|
||||||
result = filtered_result
|
seen.add(row.timestamp)
|
||||||
|
result = filtered_result
|
||||||
|
if limit:
|
||||||
|
result = result[:limit]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if resolve_references:
|
if resolve_references:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user