MCPcopy Create free account
hub / github.com/Flagsmith/flagsmith / generate_body_comment

Function generate_body_comment

api/integrations/github/github.py:125–183  ·  view source on GitHub ↗
(
    name: str,
    event_type: str,
    feature_id: int,
    feature_states: list[dict[str, typing.Any]],
    project_id: int | None = None,
    segment_name: str | None = None,
)

Source from the content-addressed store, hash-verified

123
124
125def generate_body_comment(
126 name: str,
127 event_type: str,
128 feature_id: int,
129 feature_states: list[dict[str, typing.Any]],
130 project_id: int | None = None,
131 segment_name: str | None = None,
132) -> str:
133 is_removed = event_type == GitHubEventType.FEATURE_EXTERNAL_RESOURCE_REMOVED.value
134 is_segment_override_deleted = (
135 event_type == GitHubEventType.SEGMENT_OVERRIDE_DELETED.value
136 )
137
138 if event_type == GitHubEventType.FLAG_DELETED.value:
139 return DELETED_FEATURE_TEXT % (name)
140
141 if is_removed:
142 return UNLINKED_FEATURE_TEXT % (name)
143
144 if is_segment_override_deleted and segment_name is not None:
145 return DELETED_SEGMENT_OVERRIDE_TEXT % (segment_name, name)
146
147 result = ""
148 if event_type == GitHubEventType.FLAG_UPDATED.value:
149 result = UPDATED_FEATURE_TEXT % (name)
150 else:
151 result = LINK_FEATURE_TITLE % (name)
152
153 last_segment_name = ""
154 if len(feature_states) > 0 and not feature_states[0].get("segment_name"):
155 result += FEATURE_TABLE_HEADER
156
157 for fs in feature_states:
158 feature_value = fs.get("feature_state_value")
159 tab = "segment-overrides" if fs.get("segment_name") is not None else "value"
160 environment_link_url = FEATURE_ENVIRONMENT_URL % (
161 get_current_site_url(),
162 project_id,
163 fs.get("environment_api_key"),
164 feature_id,
165 tab,
166 )
167 if (
168 fs.get("segment_name") is not None
169 and fs["segment_name"] != last_segment_name
170 ):
171 result += "\n" + LINK_SEGMENT_TITLE % (fs["segment_name"])
172 last_segment_name = fs["segment_name"]
173 result += FEATURE_TABLE_HEADER
174 table_row = FEATURE_TABLE_ROW % (
175 fs["environment_name"],
176 environment_link_url,
177 "✅ Enabled" if fs["enabled"] else "❌ Disabled",
178 f"`{feature_value}`" if feature_value else "",
179 fs["last_updated"],
180 )
181 result += table_row
182

Callers 1

send_post_requestFunction · 0.90

Calls 2

get_current_site_urlFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…