def compare_lists_and_update()

in Back-End/lambdas/receive_sqs_message.py [0:0]


def compare_lists_and_update(boto_list, dynamo_list):
    current_ids = [item['Id'] for item in boto_list]
    existing_ids = [item['Id'] for item in dynamo_list]
    
    for existing_id in existing_ids:
        if existing_id not in current_ids:
            dynamo_delete_item(existing_id)
    
    for resource in boto_list:
        strip_empty_values = {k: v for k, v in resource.items() if v}
        dynamo_put_item(strip_empty_values)