in api/wheel_participant.py [0:0]
def suggest_participant(event):
"""
Returns a suggested participant to be selected by the next wheel spin
:param event: Lambda event containing the API Gateway request path parameter wheel_id
{
"pathParameters":
{
"wheel_id": string ID of the wheel (DDB Hash Key)
},
}
:return: response dictionary containing a selected participant_id
{
"body":
{
"participant_id": string ID of the suggested participant (DDB Hash Key),
"rigged": True (if rigged, otherwise this key is not present)
}
}
"""
wheel_id = event['pathParameters']['wheel_id']
wheel = Wheel.get_existing_item(Key={'id': wheel_id})
if 'rigging' in wheel:
participant_id = wheel['rigging']['participant_id']
# Use rigging only if the rigged participant is still available
if 'Item' in WheelParticipant.get_item(Key={'wheel_id': wheel_id, 'id': participant_id}):
return_value = {'participant_id': participant_id}
# Only return rigged: True if we're not using hidden rigging
if not wheel['rigging'].get('hidden', False):
return_value['rigged'] = True
return return_value
return {'participant_id': choice_algorithm.suggest_participant(wheel)}