|
| 1 | +# This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | +# License, v. 2.0. If a copy of the MPL was not distributed with this file, |
| 3 | +# You can obtain one at http://mozilla.org/MPL/2.0/. |
| 4 | + |
| 5 | +from bugbot import utils |
| 6 | +from bugbot.bzcleaner import BzCleaner |
| 7 | +from bugbot.nag_me import Nag |
| 8 | + |
| 9 | + |
| 10 | +class TopcrashNotify(BzCleaner, Nag): |
| 11 | + def __init__(self, number_of_weeks: int = 1): |
| 12 | + """Constructor |
| 13 | +
|
| 14 | + Args: |
| 15 | + number_of_weeks: Number of weeks to consider when looking for |
| 16 | + recent activity |
| 17 | + """ |
| 18 | + super(TopcrashNotify, self).__init__() |
| 19 | + self.nweeks = number_of_weeks |
| 20 | + |
| 21 | + def description(self): |
| 22 | + return "Bugs with a ni on a bug with topcrash keyword without activity for the last {} {}".format( |
| 23 | + self.nweeks, utils.plural("week", self.nweeks) |
| 24 | + ) |
| 25 | + |
| 26 | + def get_extra_for_template(self): |
| 27 | + return {"nweeks": self.nweeks} |
| 28 | + |
| 29 | + def get_extra_for_nag_template(self): |
| 30 | + return self.get_extra_for_template() |
| 31 | + |
| 32 | + def has_last_comment_time(self): |
| 33 | + return True |
| 34 | + |
| 35 | + def has_needinfo(self): |
| 36 | + return True |
| 37 | + |
| 38 | + def columns(self): |
| 39 | + return ["id", "summary", "needinfos", "last_comment"] |
| 40 | + |
| 41 | + def columns_nag(self): |
| 42 | + return ["id", "summary", "to", "from", "last_comment"] |
| 43 | + |
| 44 | + def get_priority(self, bug): |
| 45 | + return "normal" |
| 46 | + |
| 47 | + def set_people_to_nag(self, bug, buginfo): |
| 48 | + priority = self.get_priority(bug) |
| 49 | + if not self.filter_bug(priority): |
| 50 | + return None |
| 51 | + |
| 52 | + has_manager = False |
| 53 | + for flag in bug["flags"]: |
| 54 | + if flag.get("name", "") == "needinfo" and flag["status"] == "?": |
| 55 | + requestee = flag["requestee"] |
| 56 | + buginfo["to"] = requestee |
| 57 | + moz_name = self.get_people().get_moz_name(flag["setter"]) |
| 58 | + buginfo["from"] = moz_name if moz_name is not None else flag["setter"] |
| 59 | + if self.add(requestee, buginfo, priority=priority): |
| 60 | + has_manager = True |
| 61 | + |
| 62 | + if not has_manager: |
| 63 | + self.add_no_manager(buginfo["id"]) |
| 64 | + |
| 65 | + return bug |
| 66 | + |
| 67 | + def get_bz_params(self, date): |
| 68 | + fields = ["flags", "_custom"] |
| 69 | + params = { |
| 70 | + "include_fields": fields, |
| 71 | + "resolution": "---", |
| 72 | + "f1": "days_elapsed", |
| 73 | + "o1": "greaterthan", |
| 74 | + "v1": self.nweeks * 7, |
| 75 | + "f2": "flagtypes.name", |
| 76 | + "o2": "casesubstring", |
| 77 | + "v2": "needinfo?", |
| 78 | + "f3": "keywords", |
| 79 | + "o3": "anyexact", |
| 80 | + "v3": ["topcrash", "topcrash-startup"], |
| 81 | + "f4": "keywords", |
| 82 | + "o4": "nowords", |
| 83 | + "v4": ["meta", "stalled"], |
| 84 | + } |
| 85 | + |
| 86 | + return params |
| 87 | + |
| 88 | + |
| 89 | +if __name__ == "__main__": |
| 90 | + TopcrashNotify().run() |
0 commit comments