mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Database now returns real rank in charts
This commit is contained in:
parent
15d4a588d8
commit
752832db88
18
database.py
18
database.py
@ -965,7 +965,14 @@ def db_aggregate_full(by=None,since=None,to=None,within=None,artist=None):
|
|||||||
charts[a] = charts.setdefault(a,0) + 1
|
charts[a] = charts.setdefault(a,0) + 1
|
||||||
|
|
||||||
ls = [{"artist":getArtistObject(ARTISTS[a]),"scrobbles":charts[a],"counting":coa.getAllAssociated(ARTISTS[a])} for a in charts]
|
ls = [{"artist":getArtistObject(ARTISTS[a]),"scrobbles":charts[a],"counting":coa.getAllAssociated(ARTISTS[a])} for a in charts]
|
||||||
return sorted(ls,key=lambda k:k["scrobbles"], reverse=True)
|
ls.sort(key=lambda k:k["scrobbles"],reverse=True)
|
||||||
|
# add ranks
|
||||||
|
for rnk in range(len(ls)):
|
||||||
|
if rnk == 0 or ls[rnk]["scrobbles"] < ls[rnk-1]["scrobbles"]:
|
||||||
|
ls[rnk]["rank"] = rnk + 1
|
||||||
|
else:
|
||||||
|
ls[rnk]["rank"] = ls[rnk-1]["rank"]
|
||||||
|
return ls
|
||||||
|
|
||||||
elif (by=="TRACK"):
|
elif (by=="TRACK"):
|
||||||
charts = {}
|
charts = {}
|
||||||
@ -976,7 +983,14 @@ def db_aggregate_full(by=None,since=None,to=None,within=None,artist=None):
|
|||||||
charts[track] = charts.setdefault(track,0) + 1
|
charts[track] = charts.setdefault(track,0) + 1
|
||||||
|
|
||||||
ls = [{"track":getTrackObject(TRACKS[t]),"scrobbles":charts[t]} for t in charts]
|
ls = [{"track":getTrackObject(TRACKS[t]),"scrobbles":charts[t]} for t in charts]
|
||||||
return sorted(ls,key=lambda k:k["scrobbles"], reverse=True)
|
ls.sort(key=lambda k:k["scrobbles"],reverse=True)
|
||||||
|
# add ranks
|
||||||
|
for rnk in range(len(ls)):
|
||||||
|
if rnk == 0 or ls[rnk]["scrobbles"] < ls[rnk-1]["scrobbles"]:
|
||||||
|
ls[rnk]["rank"] = rnk + 1
|
||||||
|
else:
|
||||||
|
ls[rnk]["rank"] = ls[rnk-1]["rank"]
|
||||||
|
return ls
|
||||||
|
|
||||||
else:
|
else:
|
||||||
#return len([scr for scr in SCROBBLES if since < scr[1] < to])
|
#return len([scr for scr in SCROBBLES if since < scr[1] < to])
|
||||||
|
Loading…
Reference in New Issue
Block a user