From 460a2c781b3ad2ea1d2e2cdc812803ef6ec64e6b Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 30 Dec 2020 13:31:12 -0700 Subject: [PATCH] Add a hunt_id attribute and index to the database for hunts This will allow the Turbot home view to scan the hunt_id_index to find all existing hunts, (without having to scan non-hunt items from the database). --- turbot/interaction.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/turbot/interaction.py b/turbot/interaction.py index 343eca6..8fdebae 100644 --- a/turbot/interaction.py +++ b/turbot/interaction.py @@ -114,6 +114,7 @@ def new_hunt_submission(turb, payload, metadata): {'AttributeName': 'PK', 'AttributeType': 'S'}, {'AttributeName': 'SK', 'AttributeType': 'S'}, {'AttributeName': 'channel_id', 'AttributeType': 'S'}, + {'AttributeName': 'hunt_id', 'AttributeType': 'S'}, ], ProvisionedThroughput={ 'ReadCapacityUnits': 5, @@ -132,6 +133,19 @@ def new_hunt_submission(turb, payload, metadata): 'ReadCapacityUnits': 5, 'WriteCapacityUnits': 5 } + }, + { + 'IndexName': 'hunt_id_index', + 'KeySchema': [ + {'AttributeName': 'hunt_id', 'KeyType': 'HASH'} + ], + 'Projection': { + 'ProjectionType': 'ALL' + }, + 'ProvisionedThroughput': { + 'ReadCapacityUnits': 5, + 'WriteCapacityUnits': 5 + } } ] ) @@ -155,6 +169,7 @@ def new_hunt_submission(turb, payload, metadata): Item={ "PK": "hunt-{}".format(hunt_id), "SK": "hunt-{}".format(hunt_id), + "hunt_id": hunt_id, "channel_id": channel_id, "active": False, "name": name, -- 2.43.0