Skip to content

Commit

Permalink
match-history: add average_match_badge and moving_average_match_badge
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpyp committed Dec 15, 2024
1 parent 003c2c6 commit 16a5e5d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion deadlock_analytics_api/routers/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,11 @@ def get_matches_by_account_id(
res.headers["Cache-Control"] = "public, max-age=300"
account_id = utils.validate_steam_id(account_id)
query = """
SELECT DISTINCT ON(pmh.match_id) pmh.*, toBool(mi.match_id > 0) AS has_metadata
SELECT
DISTINCT ON(pmh.match_id) pmh.*,
toBool(mi.match_id > 0) AS has_metadata,
mi.match_id IS NOT null ? intDivOrZero(mi.average_badge_team0 + mi.average_badge_team1, 2): null AS average_match_badge,
round(avg(average_match_badge) OVER (ORDER BY match_id DESC ROWS BETWEEN CURRENT ROW AND 10 FOLLOWING), 2) AS moving_average_match_badge
FROM player_match_history pmh
LEFT JOIN match_info mi USING (match_id)
WHERE account_id = %(account_id)s
Expand Down

0 comments on commit 16a5e5d

Please sign in to comment.