def _update_job()

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


def _update_job(job_id, stats):
    try:
        return table.update_item(
            Key={"Id": job_id, "Sk": job_id,},
            ConditionExpression="#Id = :Id AND #Sk = :Sk",
            UpdateExpression="set #qt = if_not_exists(#qt, :z) + :qt, "
            "#qs = if_not_exists(#qs, :z) + :qs, "
            "#qf = if_not_exists(#qf, :z) + :qf, "
            "#qb = if_not_exists(#qb, :z) + :qb, "
            "#qm = if_not_exists(#qm, :z) + :qm, "
            "#ou = if_not_exists(#ou, :z) + :ou, "
            "#os = if_not_exists(#os, :z) + :os, "
            "#of = if_not_exists(#of, :z) + :of, "
            "#or = if_not_exists(#or, :z) + :or",
            ExpressionAttributeNames={
                "#Id": "Id",
                "#Sk": "Sk",
                "#qt": "TotalQueryCount",
                "#qs": "TotalQuerySucceededCount",
                "#qf": "TotalQueryFailedCount",
                "#qb": "TotalQueryScannedInBytes",
                "#qm": "TotalQueryTimeInMillis",
                "#ou": "TotalObjectUpdatedCount",
                "#os": "TotalObjectUpdateSkippedCount",
                "#of": "TotalObjectUpdateFailedCount",
                "#or": "TotalObjectRollbackFailedCount",
            },
            ExpressionAttributeValues={
                ":Id": job_id,
                ":Sk": job_id,
                ":qt": stats.get("TotalQueryCount", 0),
                ":qs": stats.get("TotalQuerySucceededCount", 0),
                ":qf": stats.get("TotalQueryFailedCount", 0),
                ":qb": stats.get("TotalQueryScannedInBytes", 0),
                ":qm": stats.get("TotalQueryTimeInMillis", 0),
                ":ou": stats.get("TotalObjectUpdatedCount", 0),
                ":os": stats.get("TotalObjectUpdateSkippedCount", 0),
                ":of": stats.get("TotalObjectUpdateFailedCount", 0),
                ":or": stats.get("TotalObjectRollbackFailedCount", 0),
                ":z": 0,
            },
            ReturnValues="ALL_NEW",
        )["Attributes"]
    except ddb.meta.client.exceptions.ConditionalCheckFailedException:
        logger.warning("Job %s does not exist", job_id)