Skip to content

Commit 93037b8

Browse files
committed
Conditionally create team->team edge if the team has been assigned to a specific github org
1 parent 3b0aa0d commit 93037b8

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

src/openhound_github/models/enterprise_team_organization.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,34 @@ def enterprise_team_node_id(self) -> str:
4848
return enterprise_team_node_id(self.enterprise_node_id, self.team_id)
4949

5050
@property
51-
def edges(self):
51+
def _assigned_to_edge(self):
5252
yield Edge(
5353
kind=ek.ASSIGNED_TO,
5454
start=EdgePath(value=self.enterprise_team_node_id, match_by="id"),
5555
end=EdgePath(value=self.node_id, match_by="id"),
5656
properties=EdgeProperties(traversable=False),
5757
)
58-
yield Edge(
59-
kind=ek.MEMBER_OF,
60-
start=EdgePath(value=self.enterprise_team_node_id, match_by="id"),
61-
end=ConditionalEdgePath(
62-
kind=nk.TEAM,
63-
property_matchers=[
64-
PropertyMatch(key="environmentid", value=self.node_id),
65-
PropertyMatch(key="slug", value=self.projected_slug),
66-
],
67-
),
68-
properties=EdgeProperties(traversable=True),
69-
)
58+
59+
@property
60+
def member_of_team_edges(self):
61+
org_login = self.login or self._lookup.org_login_for_id(self.node_id)
62+
if org_login and self._lookup.projected_enterprise_team_exists(
63+
org_login, self.projected_slug
64+
):
65+
yield Edge(
66+
kind=ek.MEMBER_OF,
67+
start=EdgePath(value=self.enterprise_team_node_id, match_by="id"),
68+
end=ConditionalEdgePath(
69+
kind=nk.TEAM,
70+
property_matchers=[
71+
PropertyMatch(key="environmentid", value=self.node_id.upper()),
72+
PropertyMatch(key="slug", value=self.projected_slug),
73+
],
74+
),
75+
properties=EdgeProperties(traversable=True),
76+
)
77+
78+
@property
79+
def edges(self):
80+
yield from self._assigned_to_edge
81+
yield from self.member_of_team_edges

0 commit comments

Comments
 (0)