From aa5d55124d895b547cc701c285cb1d3c6a6f2abf Mon Sep 17 00:00:00 2001 From: Brad Brown Date: Fri, 10 Jun 2022 09:00:34 -0500 Subject: [PATCH] filter score getter to active players --- wordlinator/db/pg.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wordlinator/db/pg.py b/wordlinator/db/pg.py index 42a5ea7..f5fc944 100644 --- a/wordlinator/db/pg.py +++ b/wordlinator/db/pg.py @@ -126,7 +126,13 @@ class WordleDb: def get_scores(self, round_no): round = self.get_or_create_round(round_no) - return list(Score.select().filter(Score.game_id == round.game_id)) + res = ( + Score.select(Score, Player.game_id) + .join(Player, on=(Score.user_id == Player.user_id)) + .filter(Player.game_id == round.game_id) + .filter(Score.game_id == round.game_id) + ) + return list(res) def bulk_insert_scores(self, scores: typing.List[typing.Dict]): with db.atomic():