def store_text_log_summary_artifact()

in treeherder/etl/artifact.py [0:0]


def store_text_log_summary_artifact(job, text_log_summary_artifact):
    """
    Store the contents of the text log summary artifact
    """
    errors = json.loads(text_log_summary_artifact["blob"])["errors"]

    log_errors = TextLogError.objects.bulk_create(
        [
            TextLogError(
                job=job,
                line_number=error["linenumber"],
                line=astral_filter(error["line"]),
            )
            for error in errors
        ],
        # Duplicate error lines may be processed
        ignore_conflicts=True,
    )

    # Bulk create doesn't return .id field, so query to get them.
    log_errors = TextLogError.objects.filter(job=job)

    # get error summary immediately (to warm the cache)
    # Conflicts may have occured during the insert, but we pass the queryset for performance
    bugs = error_summary.get_error_summary(job, queryset=log_errors)
    for suggestion in bugs:
        if (suggestion["failure_new_in_rev"] or suggestion["counter"] == 0) and job.result not in [
            "success",
            "unknown",
            "usercancel",
            "retry",
        ]:
            # classify job as `new failure` - for filtering, etc.
            job.failure_classification_id = 6
            job.save(update_fields=["failure_classification_id"])
            # for every log_errors (TLE object) there is a corresponding bugs/suggestion
            for tle in log_errors:
                if tle.line_number == suggestion["line_number"]:
                    tle.new_failure = True
                    tle.save(update_fields=["new_failure"])
                    break