From cd714ae430b8632a35228329761e2f57114f1802 Mon Sep 17 00:00:00 2001 From: Brad Brown Date: Wed, 8 Jun 2022 08:13:26 -0500 Subject: [PATCH] limit user list to current round players --- wordlinator/db/pg.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wordlinator/db/pg.py b/wordlinator/db/pg.py index b716b7c..0a10399 100644 --- a/wordlinator/db/pg.py +++ b/wordlinator/db/pg.py @@ -129,15 +129,21 @@ class WordleDb: def get_users_without_score(self, round_no, hole_no, tweetable=True): hole = self.get_or_create_hole(round_no, hole_no) + # Find users who *have* played in this round, + # but have no score on the current hole query_str = """SELECT username FROM user_tbl u WHERE NOT EXISTS ( SELECT FROM score WHERE score.user_id = u.user_id AND score.hole_id = {} - )""".format( - hole.hole_id + ) AND EXISTS ( + SELECT FROM score WHERE score.user_id = u.user_id AND score.game_id = {} + ) + """.format( + hole.hole_id, hole.game_id ) if tweetable: + # Restrict to users who post scores on twitter query_str += " AND u.check_twitter = true" res = db.execute_sql(query_str)