<commit_before>import logging

logger = logging.getLogger(__name__)


class CallistoCoreMatchingApi(object):

    @property
    def match_reports(_):
        from callisto_core.delivery.models import MatchReport
        return MatchReport.objects.all()

    @property
    def transforms(self):
        return [
            self._resolve_decryptable_reports,
            self._resolve_duplicate_owners,
            self._resolve_single_report,
            self._update_match_found,
        ]

    def find_matches(self, identifier):
        self.identifier = identifier
        match_list = self.match_reports

        logger.debug(f'all reports => match_reports:{len(match_list)}')
        for func in self.transforms:
            if match_list:
                match_list = func(match_list)
                logger.debug(f'post {func.__name__} => {match_list}')

        if match_list:
            logger.info(f"matches found => match_reports:{len(match_list)}")

        return match_list

    def _resolve_decryptable_reports(self, match_list):
        return [
            report
            for report in match_list
            if report.get_match(self.identifier)
        ]

    def _resolve_duplicate_owners(self, match_list):
        new_match_list = []
        report_owners = []

        for match in match_list:
            if match.report.owner not in report_owners:
                new_match_list.append(match)
                report_owners.append(match.report.owner)

        return new_match_list

    def _resolve_single_report(self, match_list):
        if len(match_list) == 1:
            return []
        else:
            return match_list

    def _update_match_found(self, match_list):
        for match in match_list:
            match.report.match_found = True
            match.report.save()
        return match_list
<commit_msg>dont alert users twice of matches<commit_after>import logging

logger = logging.getLogger(__name__)


class CallistoCoreMatchingApi(object):

    @property
    def match_reports(_):
        from callisto_core.delivery.models import MatchReport
        return MatchReport.objects.all()

    @property
    def transforms(self):
        return [
            self._resolve_decryptable_reports,
            self._resolve_duplicate_owners,
            self._resolve_single_report,
            self._resolve_already_matched,
            self._update_match_found,
        ]

    def find_matches(self, identifier):
        self.identifier = identifier
        match_list = self.match_reports

        logger.debug(f'all reports => match_reports:{len(match_list)}')
        for func in self.transforms:
            if match_list:
                match_list = func(match_list)
                logger.debug(f'post {func.__name__} => {match_list}')

        if match_list:
            logger.info(f"matches found => match_reports:{len(match_list)}")

        return match_list

    def _resolve_decryptable_reports(self, match_list):
        return [
            match_report
            for match_report in match_list
            if match_report.get_match(self.identifier)
        ]

    def _resolve_duplicate_owners(self, match_list):
        new_match_list = []
        report_owners = []

        for match in match_list:
            if match.report.owner not in report_owners:
                new_match_list.append(match)
                report_owners.append(match.report.owner)

        return new_match_list

    def _resolve_single_report(self, match_list):
        if len(match_list) == 1:
            return []
        else:
            return match_list

    def _resolve_already_matched(self, match_list):
        return [
            match_report
            for match_report in match_list
            if not match_report.report.match_found
        ]

    def _update_match_found(self, match_list):
        for match in match_list:
            match.report.match_found = True
            match.report.save()
        return match_list

{'fraction_non_alphanumeric': 0.07314629258517034, 'fraction_numerical': 0.000501002004008016, 'mean_word_length': 2.131764705882353, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3196710', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1073, 'n_words': 222}