def filter_bugs()

in bugbot/rules/prod_comp_changed_with_priority.py [0:0]


    def filter_bugs(self, bugs):
        def history_handler(bug, data):
            priority_date = None
            prod_comp_date = None
            priority_who = None
            prod_comp_who = None
            prod = False
            comp = False
            bugid = str(bug["id"])
            for h in bug["history"]:
                for change in h["changes"]:
                    if change["field_name"] == "priority":
                        priority_date = dateutil.parser.parse(h["when"])
                        priority_who = h["who"]
                    elif (
                        change["field_name"] in {"product", "component"}
                        and h["who"] not in self.skiplist
                    ):
                        prod_comp_date = dateutil.parser.parse(h["when"])
                        prod_comp_who = h["who"]
                        if priority_date is not None and priority_date < prod_comp_date:
                            if change["field_name"] == "product":
                                prod = True
                            else:
                                comp = True

            if (
                priority_date is None
                or prod_comp_date is None
                or priority_date >= prod_comp_date
                or priority_who == prod_comp_who
            ):
                del data[bugid]
            else:
                data[bugid]["change_type"] = ProdCompChangedWithPriority.CHANGE[
                    (prod, comp)
                ]

        bugids = list(bugs.keys())
        Bugzilla(
            bugids=bugids, historyhandler=history_handler, historydata=bugs
        ).get_data().wait()

        return bugs