]> git.cworth.org Git - turbot/commitdiff
Add a hunt_id attribute and index to the database for hunts
authorCarl Worth <cworth@cworth.org>
Wed, 30 Dec 2020 20:31:12 +0000 (13:31 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 31 Dec 2020 16:55:34 +0000 (09:55 -0700)
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

index 343eca623461b74da4fbe8d8f0b9a5001b59a58a..8fdebaeb631b34fd0692a00805590c0b87c7857d 100644 (file)
@@ -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,