Skip to content

Commit

Permalink
Merge pull request #3 from osuAkatsuki/AKAT-000-bug-fixing
Browse files Browse the repository at this point in the history
fix: clashing `modes` variables and missing null checks
  • Loading branch information
tsunyoku authored Sep 10, 2022
2 parents 868cf2c + 4a4d335 commit c518f77
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def disconnect() -> None:

print("Disconnected from database and redis")

modes = {
STR_TO_INT_MODE = {
"std": 0,
"taiko": 1,
"ctb": 2,
Expand Down Expand Up @@ -69,11 +69,14 @@ async def recalc_ranks() -> None:

for user in users:
last_score_time = await db.fetch(
f"select max(time) time from {scores_table} inner join beatmaps using(beatmap_md5) "
f"select max(time) as time from {scores_table} inner join beatmaps using(beatmap_md5) "
"where userid = %s and completed = 3 and ranked in (2, 3) and play_mode = %s order by pp desc limit 100",
[user["id"], modes[mode]]
[user["id"], STR_TO_INT_MODE[mode]]
)
inactive_days = (start_time - last_score_time["time"]) / 60 / 60 / 24
if not last_score_time or last_score_time["time"] is None:
inactive_days = 60
else:
inactive_days = (start_time - last_score_time["time"]) / 60 / 60 / 24

if inactive_days < 60 and user["privileges"] & 1:
await redis.zadd(
Expand Down

0 comments on commit c518f77

Please sign in to comment.