Fix: Support both numeric and hash song IDs for leaderboard
This commit is contained in:
9
app.py
9
app.py
@@ -858,7 +858,6 @@ def route_api_leaderboard_submit():
|
||||
|
||||
return jsonify({'status': 'ok', 'message': 'score_submitted'})
|
||||
|
||||
|
||||
@app.route(basedir + 'api/leaderboard/get')
|
||||
def route_api_leaderboard_get():
|
||||
song_id = request.args.get('song_id', None)
|
||||
@@ -867,10 +866,13 @@ def route_api_leaderboard_get():
|
||||
if not song_id or not difficulty:
|
||||
return abort(400)
|
||||
|
||||
# Accept both numeric IDs and hash strings
|
||||
# Try to convert to int if possible, otherwise use as string
|
||||
try:
|
||||
song_id = int(song_id)
|
||||
except:
|
||||
return abort(400)
|
||||
except (ValueError, TypeError):
|
||||
# Keep as string (hash ID)
|
||||
pass
|
||||
|
||||
# Validate difficulty
|
||||
valid_difficulties = ['easy', 'normal', 'hard', 'oni', 'ura']
|
||||
@@ -901,6 +903,7 @@ def route_api_leaderboard_get():
|
||||
return jsonify({'status': 'ok', 'leaderboard': leaderboard, 'month': current_month})
|
||||
|
||||
|
||||
|
||||
@app.route(basedir + 'privacy')
|
||||
def route_api_privacy():
|
||||
last_modified = time.strftime('%d %B %Y', time.gmtime(os.path.getmtime('templates/privacy.txt')))
|
||||
|
||||
Reference in New Issue
Block a user