def handle_bug()

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


    def handle_bug(self, bug, data):
        is_no_assignee = utils.is_no_assignee(bug["assigned_to"])
        last_comment = self._get_last_comment(bug)

        # If we commented before, we want to send reminders when we are close to
        # the soft freeze.
        is_reminder = bool(last_comment)
        if is_reminder:
            if self.is_weekend or not is_no_assignee or not self.is_soft_freeze_soon:
                return None

            # Post reminders based on the configured interval
            last_reminder_comment = self._get_last_reminder_comment(bug)
            last_comment_time = (
                last_reminder_comment["time"]
                if last_reminder_comment
                else last_comment["time"]
            )
            if last_comment_time > self.reminder_comment_date:
                return None

        bugid = str(bug["id"])

        def format_flag(flag: dict) -> str:
            tracking_type = (
                "tracked for" if bug[flag["tracking_field"]] == "+" else "blocking"
            )
            version = flag["version"]
            channel = flag["channel"]
            return f"{tracking_type} firefox{version} ({channel})"

        tracking_statuses = [
            format_flag(flag)
            for flag in self.version_flags
            if bug.get(flag["tracking_field"]) in ("blocking", "+")
            and bug.get(flag["status_field"]) in ("affected", "---")
        ]
        assert tracking_statuses

        reasons = []
        solutions = []
        if is_no_assignee:
            reasons.append("isn't assigned")
            solutions.append("find an assignee")
        if bug["priority"] in LOW_PRIORITY:
            reasons.append("has low priority")
            solutions.append("increase the priority")
        if not is_reminder and bug["severity"] in LOW_SEVERITY:
            reasons.append("has low severity")
            solutions.append("increase the severity")
        assert reasons and solutions

        # We are using the regressed_by field to identify regression instead of
        # using the regression keyword because we want to suggesting backout. We
        # can only suggest backout if we know the exact cause of the regression.
        is_regression = bool(bug["regressed_by"])

        # This is a workaround to pass the information to get_mail_to_auto_ni()
        bug["is_reminder"] = is_reminder

        data[bugid] = {
            "tracking_statuses": tracking_statuses,
            "reasons": reasons,
            "is_regression": is_regression,
            "action": "Reminder comment" if is_reminder else "Needinfo",
        }

        if is_reminder:
            assert self.is_soft_freeze_soon
            comment_num = last_comment["count"]
            self.autofix_changes[bugid] = {
                "comment": {
                    "body": (
                        f"This is a reminder regarding comment #{comment_num}!\n\n"
                        f"The bug is marked as { utils.english_list(tracking_statuses) }. "
                        "We have limited time to fix this, "
                        f"the soft freeze is { self.soft_freeze_delta }. "
                        f"However, the bug still { utils.english_list(reasons) }."
                    )
                },
            }
        else:
            need_action = is_no_assignee or bug["priority"] in LOW_PRIORITY
            self.extra_ni[bugid] = {
                "tracking_statuses": utils.english_list(tracking_statuses),
                "reasons": utils.english_list(reasons),
                "solutions": utils.english_list(solutions),
                "show_soft_freeze_comment": self.is_soft_freeze_soon and need_action,
                "show_regression_comment": is_regression and need_action,
            }

        return bug