File tree 1 file changed +2
-4
lines changed
listenbrainz/webserver/views
1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change 9
9
import listenbrainz .db .user as db_user
10
10
import pycountry
11
11
import requests
12
+ import heapq
12
13
13
14
from data .model .common_stat import StatApi , StatisticsRange , StatRecordList
14
15
from data .model .user_artist_map import UserArtistMapRecord , UserArtistMapArtist
@@ -434,10 +435,7 @@ def _get_artist_activity(release_groups_list):
434
435
artist_data ["name" ] = artist_name
435
436
artist_data ["albums" ] = list (artist_data ["albums" ].values ())
436
437
437
- sorted_data = sorted (result .values (), key = lambda x : x ["listen_count" ], reverse = True )
438
- count = 15
439
- N = min (count , len (sorted_data ))
440
- return sorted_data [:N ]
438
+ return heapq .nlargest (15 , result .values (), key = lambda x : x ["listen_count" ])
441
439
442
440
@stats_api_bp .get ("/user/<user_name>/artist-activity" )
443
441
@crossdomain
You can’t perform that action at this time.
0 commit comments