[Refactor] Performance optimization

- Put download token in memory database
- Accelerate multiple querying in `best_score` table
This commit is contained in:
Lost-MSth
2022-11-01 18:08:02 +08:00
parent e04c8ecf2d
commit cf350842ac
11 changed files with 168 additions and 137 deletions

View File

@@ -29,12 +29,14 @@ def game_info():
@auth_required(request)
@arc_try
def download_song(user_id):
with Connect() as c:
x = DownloadList(c, UserOnline(c, user_id))
with Connect(in_memory=True) as c:
x = DownloadList(c, UserOnline(None, user_id))
x.song_ids = request.args.getlist('sid')
x.url_flag = json.loads(request.args.get('url', 'true'))
if x.url_flag and x.is_limited:
raise RateLimit('You have reached the download limit.', 903)
if x.url_flag:
x.clear_download_token()
x.add_songs()
return success_return(x.urls)