Skip to content

Commit

Permalink
Merge pull request #134 from Yuisyuu/main
Browse files Browse the repository at this point in the history
Fix sorting of b50 and b40
  • Loading branch information
Diving-Fish authored Jul 21, 2024
2 parents 361976f + 03b9064 commit 005b2bf
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions database/routes/maimai.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,25 +273,6 @@ async def dev_get_record():
return records


def get_ra_in(rate: str) -> int:
return [
"sssp",
"sss",
"ssp",
"ss",
"sp",
"s",
"aaa",
"aa",
"a",
"bbb",
"bb",
"b",
"c",
"d",
].index(rate)


def get_dx_and_sd(player):
l = NewRecord.raw('select newrecord.achievements, newrecord.fc, newrecord.fs, newrecord.dxScore, chart.ds as ds, chart.level as level, chart.difficulty as diff, music.type as `type`, music.id as `id`, music.is_new as is_new, music.title as title from newrecord, chart, music where player_id = %s and chart_id = chart.id and chart.music_id = music.id', player.id)
l1 = []
Expand All @@ -302,8 +283,8 @@ def get_dx_and_sd(player):
l2.append(r)
else:
l1.append(r)
l1.sort(key=lambda x: (x.ra, get_ra_in(x.rate), x.ds, x.achievements), reverse=True)
l2.sort(key=lambda x: (x.ra, get_ra_in(x.rate), x.ds, x.achievements), reverse=True)
l1.sort(key=lambda x: (x.ra, x.ds, x.achievements), reverse=True)
l2.sort(key=lambda x: (x.ra, x.ds, x.achievements), reverse=True)
return l1[:25], l2[:15]


Expand All @@ -317,8 +298,8 @@ def get_dx_and_sd_for50(player):
l2.append(r)
else:
l1.append(r)
l1.sort(key=lambda x: (x.ra, get_ra_in(x.rate), x.ds, x.achievements), reverse=True)
l2.sort(key=lambda x: (x.ra, get_ra_in(x.rate), x.ds, x.achievements), reverse=True)
l1.sort(key=lambda x: (x.ra, x.ds, x.achievements), reverse=True)
l2.sort(key=lambda x: (x.ra, x.ds, x.achievements), reverse=True)
return l1[:35], l2[:15]


Expand Down

0 comments on commit 005b2bf

Please sign in to comment.