]> git.cworth.org Git - turbot/commitdiff
Home: Update query for finding puzzles to new all-one-table schema
authorCarl Worth <cworth@cworth.org>
Thu, 31 Dec 2020 17:22:04 +0000 (10:22 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 31 Dec 2020 19:05:16 +0000 (12:05 -0700)
Previously, we looked in a separate per-hunt table to find the puzzles
for a hunt. Now, instead, we look in the single "turbot" table and
find puzzles for a hunt by looking for items whose PK is
"hunt-<HUNT_ID>" and whose SK starts with "puzzle-".

.flake8
turbot/events.py

diff --git a/.flake8 b/.flake8
index f31fa665927abbd3a03330abc4ebb009ccf8f1f0..45750546d34811fee266e52bf017536692904ff3 100644 (file)
--- a/.flake8
+++ b/.flake8
@@ -1,2 +1,2 @@
 [flake8]
-ignore = E251, E305, E302, W503, E201, E202, E225, E226, E203
+ignore = E251, E305, E302, W503, E201, E202, E225, E226, E203, W504
index 9439a2396be6445ca9eb91c4b882c66b188f5bc1..bbc00b63bccf8b74c578ed0f3e4d6e3372c91e8e 100644 (file)
@@ -58,7 +58,12 @@ def hunt_block(turb, hunt):
     hunt_id = hunt['hunt_id']
     channel_id = hunt['channel_id']
 
-    response = turb.db.Table(hunt_id).scan()
+    response = turb.table.query(
+        KeyConditionExpression=(
+            Key('PK').eq('hunt-{}'.format(hunt_id)) &
+            Key('SK').begins_with('puzzle-')
+        )
+    )
     puzzles = response['Items']
 
     hunt_text = "*<{}|{}>*".format(channel_url(channel_id), name)