def create_autoclassify_job_note(self, job, user=None):
        """
        Create a JobNote, possibly via auto-classification.

        Create mappings from the given Job to Bugs via verified Classifications
        of this Job.

        Also creates a JobNote.
        """
        # Only insert bugs for verified failures since these are automatically
        # mirrored to ES and the mirroring can't be undone
        # TODO: Decide whether this should change now that we're no longer mirroring.
        bug_numbers = set(ClassifiedFailure.objects
                          .filter(best_for_errors__text_log_error__step__job=job,
                                  best_for_errors__best_is_verified=True)
                          .exclude(bug_number=None)
                          .exclude(bug_number=0)
                          .values_list('bug_number', flat=True))

        existing_maps = set(BugJobMap.objects.filter(bug_id__in=bug_numbers)
                                             .values_list('bug_id'))

        for bug_number in (bug_numbers - existing_maps):
            BugJobMap.objects.create(job_id=job.id, bug_id=bug_number, user=user)

        # if user is not specified, then this is an autoclassified job note and
        # we should mark it as such
        classification_name = 'intermittent' if user else 'autoclassified intermittent'
        classification = FailureClassification.objects.get(name=classification_name)

        return JobNote.objects.create(job=job,
                                      failure_classification=classification,
                                      user=user,
                                      text="")
def create_autoclassify_job_note ( self , job , user = None ) : bug_numbers = set ( ClassifiedFailure . objects . filter ( best_for_errors__text_log_error__step__job = job , best_for_errors__best_is_verified = True ) . exclude ( bug_number = None ) . exclude ( bug_number = 0 ) . values_list ( 'bug_number' , flat = True ) ) existing_maps = set ( BugJobMap . objects . filter ( bug_id__in = bug_numbers ) . values_list ( 'bug_id' ) ) for bug_number in ( bug_numbers - existing_maps ) : BugJobMap . objects . create ( job_id = job . id , bug_id = bug_number , user = user ) classification_name = 'intermittent' if user else 'autoclassified intermittent' classification = FailureClassification . objects . get ( name = classification_name ) return JobNote . objects . create ( job = job , failure_classification = classification , user = user , text = "" )
Create a JobNote, possibly via auto-classification.

        Create mappings from the given Job to Bugs via verified Classifications
        of this Job.

        Also creates a JobNote.