From 0d1df2ea1359a09a59fc897323d2d0080fe1f86a Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sun, 10 Jan 2021 09:51:15 -0800 Subject: [PATCH] Rename identifier from item to hunt The dynamodb API uses the generic term "item", but our code is more clear with the more distinctive term "hunt" for the identifier here. This commit has no functional change. --- turbot/events.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/turbot/events.py b/turbot/events.py index b8fd429..cae4ccf 100644 --- a/turbot/events.py +++ b/turbot/events.py @@ -103,40 +103,40 @@ def hunt_channel_created(turb, channel_name, channel_id): .format(channel_id) + "Letting Slack retry this event") return lambda_error - item = response['Items'][0] + hunt = response['Items'][0] - if 'sheet_url' in item: + if 'sheet_url' in hunt: print("Info: channel_id {} already has sheet_url {}. Exiting." - .format(channel_id, item['sheet_url'])) + .format(channel_id, hunt['sheet_url'])) return lambda_success # Before launching into sheet creation, indicate that we're doing this # in the database. This way, if we take too long to create the sheet # and Slack retries the event, that next event will see this 'pending' # string and cleanly return (eliminating all future retries). - item['sheet_url'] = 'pending' - turb.table.put_item(Item=item) + hunt['sheet_url'] = 'pending' + turb.table.put_item(Item=hunt) # Also, let the channel users know what we are up to slack_send_message( turb.slack_client, channel_id, - "Welcome to the channel for the {} hunt! ".format(item['name']) + "Welcome to the channel for the {} hunt! ".format(hunt['name']) + "Please wait a minute or two while I create some backend resources.") # Create a sheet for the hunt - sheet = sheets_create(turb, item['name']) + sheet = sheets_create(turb, hunt['name']) # Update the database with the URL of the sheet - item['sheet_url'] = sheet['url'] - turb.table.put_item(Item=item) + hunt['sheet_url'] = sheet['url'] + turb.table.put_item(Item=hunt) # Message the channel with the URL of the sheet slack_send_message(turb.slack_client, channel_id, "Sheet created for this hunt: {}".format(sheet['url'])) # Mark the hunt as active in the database - item['active'] = True - turb.table.put_item(Item=item) + hunt['active'] = True + turb.table.put_item(Item=hunt) # Message the hunt channel that the database is ready slack_send_message( -- 2.43.0