drop txn wrapper on raw sql
This commit is contained in:
@@ -240,25 +240,24 @@ class WordleDb:
|
|||||||
score.save()
|
score.save()
|
||||||
|
|
||||||
def get_users_without_score(self, round_no, hole_no, tweetable=True):
|
def get_users_without_score(self, round_no, hole_no, tweetable=True):
|
||||||
with db.atomic() as txn:
|
hole = self.get_or_create_hole(round_no, hole_no)
|
||||||
hole = self.get_or_create_hole(round_no, hole_no)
|
# Find users who *have* played in this round,
|
||||||
# Find users who *have* played in this round,
|
# but have no score on the current hole
|
||||||
# but have no score on the current hole
|
query_str = """SELECT u.username, player.game_id
|
||||||
query_str = """SELECT u.username, player.game_id
|
FROM user_tbl u
|
||||||
FROM user_tbl u
|
JOIN player ON player.user_id = u.user_id
|
||||||
JOIN player ON player.user_id = u.user_id
|
WHERE (
|
||||||
WHERE (
|
player.game_id = {}
|
||||||
player.game_id = {}
|
) AND NOT EXISTS (
|
||||||
) AND NOT EXISTS (
|
SELECT FROM score WHERE score.user_id = u.user_id AND score.hole_id = {}
|
||||||
SELECT FROM score WHERE score.user_id = u.user_id AND score.hole_id = {}
|
)
|
||||||
)
|
""".format(
|
||||||
""".format(
|
hole.game_id, hole.hole_id
|
||||||
hole.game_id, hole.hole_id
|
)
|
||||||
)
|
|
||||||
|
|
||||||
if tweetable:
|
if tweetable:
|
||||||
# Restrict to users who post scores on twitter
|
# Restrict to users who post scores on twitter
|
||||||
query_str += " AND u.check_twitter = true"
|
query_str += " AND u.check_twitter = true"
|
||||||
|
|
||||||
res = txn.execute_sql(query_str)
|
res = db.execute_sql(query_str)
|
||||||
return [r[0] for r in res]
|
return [r[0] for r in res]
|
||||||
|
|||||||
Reference in New Issue
Block a user