]> git.cworth.org Git - turbot/commitdiff
Rename hunt_id_index to is_hunt_index
authorCarl Worth <cworth@cworth.org>
Thu, 31 Dec 2020 19:52:43 +0000 (11:52 -0800)
committerCarl Worth <cworth@cworth.org>
Thu, 31 Dec 2020 19:52:43 +0000 (11:52 -0800)
Backed, of course, by a new is_hunt attribute.

The rationale here is that the whole point of this index is to be a
sparse attribute so that the code can efficiently query all existing
hunts. But meanwhile, it's useful for puzzles to have a "hunt_id"
attribute, which would confict with the goal of having "hunt_id" be
sparse and populated only for hunts and not puzzles.

So the fix here is to make hunt_id universal, and instead have a
separate "is_hunt" attribute which is the sparse one, (and will
clearly never be populated for a puzzle).

turbot/events.py
turbot/interaction.py

index d7019944696f63a782270a8a20305a1e2c31499c..3b04036f8aafca480b2988ffc76a13c8629ebab5 100644 (file)
@@ -83,7 +83,7 @@ def home(turb, user_id):
     # Behave cleanly if there is no "turbot" table at all yet.
     try:
         response = turb.table.scan(
-            IndexName="hunt_id_index",
+            IndexName="is_hunt_index",
         )
         hunts = response['Items']
     except Exception:
index bb4b868179863d259c53044c3789667c95548a71..06181887beb3f1c6632dda3f21607c88aa5e6b9c 100644 (file)
@@ -115,7 +115,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'},
+                {'AttributeName': 'is_hunt', 'AttributeType': 'S'},
             ],
             ProvisionedThroughput={
                 'ReadCapacityUnits': 5,
@@ -136,9 +136,9 @@ def new_hunt_submission(turb, payload, metadata):
                     }
                 },
                 {
-                    'IndexName': 'hunt_id_index',
+                    'IndexName': 'is_hunt_index',
                     'KeySchema': [
-                        {'AttributeName': 'hunt_id', 'KeyType': 'HASH'}
+                        {'AttributeName': 'is_hunt', 'KeyType': 'HASH'}
                     ],
                     'Projection': {
                         'ProjectionType': 'ALL'
@@ -170,6 +170,7 @@ def new_hunt_submission(turb, payload, metadata):
     item={
         "PK": "hunt-{}".format(hunt_id),
         "SK": "hunt-{}".format(hunt_id),
+        "is_hunt": hunt_id,
         "hunt_id": hunt_id,
         "channel_id": channel_id,
         "active": False,