Skip to content

Commit

Permalink
fix(rank-card): Rank card should not include archived maps
Browse files Browse the repository at this point in the history
  • Loading branch information
tylovejoy committed Aug 16, 2023
1 parent 830d220 commit fd48759
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cogs/rank_card/rank_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def rank_card(

totals = await self._get_map_totals()
completions = await utils.get_completions_data(
itx.client, user.id, include_beginner=True
itx.client, user.id, include_beginner=True, include_archived=False
)
world_records = await self._get_world_record_count(user.id)
maps = await self._get_maps_count(user.id)
Expand Down
9 changes: 6 additions & 3 deletions utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ async def rank_finder(


async def get_completions_data(
client: core.Genji, user: int, include_beginner: bool = False
client: core.Genji,
user: int,
include_beginner: bool = False,
include_archived: bool = True,
) -> dict[str, tuple[int, int, int, int]]:
if include_beginner:
clause = (
Expand Down Expand Up @@ -230,7 +233,7 @@ async def get_completions_data(
FROM legacy_records
),
ranges ("range", "name") AS (
VALUES {clause}
VALUES ('[0.0,0.59)'::numrange, 'Beginner'), ('[0.59,2.35)'::numrange, 'Easy'),
('[2.35,4.12)'::numrange, 'Medium'),
('[4.12,5.88)'::numrange, 'Hard'),
Expand All @@ -252,7 +255,7 @@ async def get_completions_data(
LEFT JOIN map_medals mm ON r.map_code = mm.map_code
WHERE r.user_id = $1
AND m.official = TRUE
--AND m.archived = FALSE -- Not sure why archived don't count ?
AND ($2 IS TRUE OR m.archived = FALSE)
GROUP BY m.map_code, record, gold, silver, bronze, VERIFIED, medal, r.user_id
)
SELECT COUNT(name) AS completions,
Expand Down

0 comments on commit fd48759

Please sign in to comment.