def get_labels()

in bugbug/models/fenixcomponent.py [0:0]


    def get_labels(self):
        classes = {}

        date_limit = datetime.now(timezone.utc) - relativedelta(years=2)

        for bug_data in bugzilla.get_bugs():
            # We want the model to be aware of GeckoView bugs, as it is common
            # for bugs filed under Firefox for Android to end up in GeckoView.
            if (
                bug_data["product"] != "Firefox for Android"
                and bug_data["product"] != "GeckoView"
            ):
                continue

            # Exclude 'General' because it contains bugs that may belong to
            # other components, thus introducing noise. However, include
            # 'GeckoView::General' because the model should be able to move
            # bugs to GeckoView.
            if (
                bug_data["component"] == "General"
                and bug_data["product"] != "GeckoView"
            ):
                continue

            if dateutil.parser.parse(bug_data["creation_time"]) < date_limit:
                continue

            classes[int(bug_data["id"])] = bug_data["component"]

        # Components with less than 100 bugs are not not be very useful, so we
        # we ignore them.
        low_count_components = {
            component: count
            for component, count in Counter(classes.values()).items()
            if count < 100
        }
        bugs_to_remove = [
            bug_id
            for bug_id, component in classes.items()
            if component in low_count_components
        ]
        for bug_id in bugs_to_remove:
            del classes[bug_id]

        return classes, set(classes.values())