]> git.cworth.org Git - turbot/blobdiff - turbot/interaction.py
Rename primary-key attribute from PK to hunt_id
[turbot] / turbot / interaction.py
index 06181887beb3f1c6632dda3f21607c88aa5e6b9c..31d554942f580d11566ddfb9b91b15122e865c5a 100644 (file)
@@ -108,11 +108,11 @@ def new_hunt_submission(turb, payload, metadata):
         turb.table = turb.db.create_table(
             TableName='turbot',
             KeySchema=[
-                {'AttributeName': 'PK', 'KeyType': 'HASH'},
+                {'AttributeName': 'hunt_id', 'KeyType': 'HASH'},
                 {'AttributeName': 'SK', 'KeyType': 'RANGE'},
             ],
             AttributeDefinitions=[
-                {'AttributeName': 'PK', 'AttributeType': 'S'},
+                {'AttributeName': 'hunt_id', 'AttributeType': 'S'},
                 {'AttributeName': 'SK', 'AttributeType': 'S'},
                 {'AttributeName': 'channel_id', 'AttributeType': 'S'},
                 {'AttributeName': 'is_hunt', 'AttributeType': 'S'},
@@ -168,10 +168,9 @@ def new_hunt_submission(turb, payload, metadata):
     # (leaving it as non-active for now until the channel-created handler
     #  finishes fixing it up with a sheet and a companion table)
     item={
-        "PK": "hunt-{}".format(hunt_id),
+        "hunt_id": hunt_id,
         "SK": "hunt-{}".format(hunt_id),
         "is_hunt": hunt_id,
-        "hunt_id": hunt_id,
         "channel_id": channel_id,
         "active": False,
         "name": name,
@@ -297,7 +296,7 @@ def find_hunt_for_hunt_id(turb, hunt_id):
     """
     turbot_table = turb.db.Table("turbot")
 
-    response = turbot_table.get_item(Key={'PK': 'hunt-{}'.format(hunt_id)})
+    response = turbot_table.get_item(Key={'hunt_id': hunt_id})
 
     if 'Item' in response:
         return response['Item']
@@ -402,7 +401,7 @@ def puzzle_submission(turb, payload, metadata):
 
     # Insert the newly-created puzzle into the database
     item={
-        "PK": "hunt-{}".format(hunt_id),
+        "hunt_id": hunt_id,
         "SK": "puzzle-{}".format(puzzle_id),
         "puzzle_id": puzzle_id,
         "channel_id": channel_id,