in treeherder/model/models.py [0:0]
def _ensure_classification(self):
"""
Ensures a single TextLogError's related bugs have Classifications.
If the linked Job has a single meaningful TextLogError:
- find the bugs currently related to it via a Classification
- find the bugs mapped to the job related to this note
- find the bugs that are mapped but not classified
- link this subset of bugs to Classifications
- if there's only one new bug and no existing ones, verify it
"""
# if this note was automatically filed, don't update the auto-classification information
if not self.user:
return
# if the failure type isn't intermittent, ignore
if self.failure_classification.name not in ["intermittent"]:
return
# if the linked Job has more than one TextLogError, ignore
text_log_error = self.job.get_manual_classification_line()
if not text_log_error:
return
# evaluate the QuerySet here so it can be used when creating new_bugs below
existing_bugs = list(
ClassifiedFailure.objects.filter(
error_matches__text_log_error=text_log_error
).values_list("bug_number", flat=True)
)
new_bugs = self.job.bugjobmap_set.exclude(bug_id__in=existing_bugs).values_list(
"bug_id", flat=True
)
if not new_bugs:
return
# Create Match instances for each new bug
for bug_number in new_bugs:
classification, _ = ClassifiedFailure.objects.get_or_create(bug_number=bug_number)
text_log_error.create_match("ManualDetector", classification)
# if there's only one new bug and no existing ones, verify it
if len(new_bugs) == 1 and not existing_bugs:
text_log_error.verify_classification(classification)