def create_note(job, all_matched):
    if not (all_matched and job.is_fully_autoclassified()):
        return

    # We don't want to add a job note after an autoclassification if there is
    # already one and after a verification if there is already one not supplied
    # by the autoclassifier
    if not JobNote.objects.filter(job=job).exists():
        JobNote.create_autoclassify_job_note(job)
Beispiel #2
0
def create_note(job, all_matched):
    if not (all_matched and job.is_fully_autoclassified()):
        return

    # We don't want to add a job note after an autoclassification if there is
    # already one and after a verification if there is already one not supplied
    # by the autoclassifier
    if not JobNote.objects.filter(job=job).exists():
        JobNote.create_autoclassify_job_note(job)
Beispiel #3
0
def update_db(job, matches, all_matched):
    matches_by_error = defaultdict(set)
    classified_failures = {
        item.id: item
        for item in ClassifiedFailure.objects.filter(
            id__in=[match.classified_failure_id for _, match in matches])
    }
    for matcher, match in matches:
        classified_failure = classified_failures[match.classified_failure_id]
        matches_by_error[match.text_log_error].add(
            (matcher, match, classified_failure))

    for text_log_error, matches in iteritems(matches_by_error):
        for (matcher, match, classified_failure) in matches:
            try:
                TextLogErrorMatch.objects.create(
                    score=match.score,
                    matcher=matcher,
                    classified_failure=classified_failure,
                    text_log_error=match.text_log_error)
                if match.text_log_error.metadata and match.text_log_error.metadata.failure_line:
                    FailureMatch.objects.create(
                        score=match.score,
                        matcher=matcher,
                        classified_failure=classified_failure,
                        failure_line=match.text_log_error.metadata.failure_line
                    )
            except IntegrityError:
                logger.warning(
                    "Tried to create duplicate match for TextLogError %i with matcher %i and classified_failure %i",
                    text_log_error.id, matcher.id, classified_failure.id)
        best_match = text_log_error.best_automatic_match(
            AUTOCLASSIFY_CUTOFF_RATIO)
        if best_match:
            text_log_error.mark_best_classification(classified_failure)

    if all_matched:
        if job.is_fully_autoclassified():
            # We don't want to add a job note after an autoclassification if there is already
            # one and after a verification if there is already one not supplied by the
            # autoclassifier
            if not JobNote.objects.filter(job=job).exists():
                JobNote.create_autoclassify_job_note(job)