• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / relman-auto-nag / #4902

29 Jan 2024 08:55AM CUT coverage: 21.783% (+0.005%) from 21.778%
#4902

push

coveralls-python

jpangas
Add accessibility template

716 of 3608 branches covered (0.0%)

1928 of 8851 relevant lines covered (21.78%)

0.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/bugbot/component_triagers.py
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 dataclasses import dataclass
×
6
from typing import Dict, List, Set
×
7

8
from libmozdata.bugzilla import BugzillaProduct
×
9

10
from bugbot.components import ComponentName
×
11
from bugbot.round_robin import RoundRobin
×
12

13

14
@dataclass
×
15
class TriageOwner:
×
16
    component: ComponentName
×
17
    bugzilla_email: str
×
18

19

20
class ComponentTriagers:
×
21
    def __init__(
×
22
        self,
23
        excluded_teams: List[str] = [],
24
    ) -> None:
25
        """Constructor
26

27
        Args:
28
            excluded_teams: teams to excluded all of their components.
29
        """
30
        self.round_robin: RoundRobin = RoundRobin.get_instance()
×
31
        self.triagers: Dict[ComponentName, str] = {}
×
32
        products = [
×
33
            ComponentName.from_str(pc).product
34
            for pc in self.round_robin.get_components()
35
        ]
36
        self._fetch_triagers(
×
37
            products,
38
            set(excluded_teams),
39
        )
40

41
    def _fetch_triagers(
×
42
        self,
43
        products: List[str],
44
        excluded_teams: Set[str],
45
    ) -> None:
46
        def handler(product, data):
×
47
            for component in product["components"]:
×
48
                component_name = ComponentName(product["name"], component["name"])
×
49
                if component["team_name"] not in excluded_teams:
×
50
                    data[component_name] = component["triage_owner"]
×
51

52
        BugzillaProduct(
×
53
            product_names=products,
54
            include_fields=[
55
                "name",
56
                "components.name",
57
                "components.team_name",
58
                "components.triage_owner",
59
            ],
60
            product_handler=handler,
61
            product_data=self.triagers,
62
        ).wait()
63

64
    def get_current_triage_owner(self, component: ComponentName) -> str:
×
65
        """Get the current triage owner as defined on Bugzilla.
66

67
        Args:
68
            component: the name of the component.
69

70
        Returns:
71
            The bugzilla email of the triage owner.
72
        """
73

74
        return self.triagers[component]
×
75

76
    def get_new_triage_owners(self) -> List[TriageOwner]:
×
77
        """Get the triage owners that are different than what are defined on
78
        Bugzilla.
79

80
        Returns:
81
            The new triage owner based on the rotation source (i.e., calendar).
82
            If the rotation source returns more than one person, the first one
83
            will be selected as the new triage owner.
84
        """
85
        triagers = []
×
86
        for component, current_triager in self.triagers.items():
×
87
            new_triager = self.round_robin.get(
×
88
                {
89
                    "product": component.product,
90
                    "component": component.name,
91
                    "triage_owner": current_triager,
92
                },
93
                "today",
94
                only_one=True,
95
                has_nick=False,
96
            )
97
            if new_triager and new_triager != current_triager:
×
98
                triagers.append(TriageOwner(component, new_triager))
×
99

100
        return triagers
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc