def handle_dynamo()

in functions/overlay_audio.py [0:0]


def handle_dynamo(event, contact_Id):
    
    bucket_name = event['target']['Bucket']
    audio_file = event['target']['Key']
    
    combined_loc = bucket_name + "/" + audio_file
    
    dynamodb = boto3.resource('dynamodb')
    
    table_name = os.getenv('contactDetailsTableName')
    print(table_name)
    
    table = dynamodb.Table(table_name)

    response = table.get_item(
       Key={
            'contactId': contact_Id
        }
    )
    item = response['Item']
    try:
        status = item['mergeStatus']
    except KeyError:
        print("no mergeStatus")
        status=""
    
    if status == "":
        print('Status is blank, updating with processing')
        table.update_item(
            Key={'contactId': contact_Id},
             UpdateExpression="set mergeStatus=:p",  
             ExpressionAttributeValues={
                ':p': 'Processing'
                }
        )
        print('Audio Merge Code')
        status = merge_audio(event)
        print('merge_audio is complete, update dynamo')
        
        table.update_item(
            Key={'contactId': contact_Id},
             UpdateExpression="set mergeStatus=:p,combinedAudio=:a",
             ExpressionAttributeValues={
                ':p': status,
                ':a': combined_loc
                }
        )
    elif status == "Processing":
        print('Status is processing, return')
    elif status == "Complete":
        print('Status is complete, we should never get here')