def update_status()

in backend/lambdas/jobs/status_updater.py [0:0]


def update_status(job_id, events):
    attr_updates = {}
    for event in events:
        # Handle non status events
        event_name = event["EventName"]
        if event_name not in status_map:
            if event_name in append_data_only_statuses:
                event_data = event.get("EventData", {})
                for attribute in append_data_only_statuses[event_name]:
                    attr_updates[attribute] = event_data[attribute]
            continue

        new_status = determine_status(job_id, event_name)
        # Only change the status if it's still in an unlocked state
        if (
            not attr_updates.get("JobStatus")
            or attr_updates.get("JobStatus") in unlocked_states
        ):
            attr_updates["JobStatus"] = new_status

        # Update any job attributes
        for attr, statuses in time_statuses.items():
            if new_status in statuses and not attr_updates.get(attr):
                attr_updates[attr] = event["CreatedAt"]

    if len(attr_updates) > 0:
        job = _update_item(job_id, attr_updates)
        logger.info("Updated Status for Job ID %s: %s", job_id, attr_updates)
        return job