From 82ef8e9a39a5701a90804ffe998de4c07a6c8324 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 31 Dec 2020 10:22:04 -0700 Subject: [PATCH] Home: Update query for finding puzzles to new all-one-table schema 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-" and whose SK starts with "puzzle-". --- .flake8 | 2 +- turbot/events.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.flake8 b/.flake8 index f31fa66..4575054 100644 --- 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 diff --git a/turbot/events.py b/turbot/events.py index 9439a23..bbc00b6 100644 --- a/turbot/events.py +++ b/turbot/events.py @@ -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) -- 2.43.0