(data: CallGithubData)
| 15 | |
| 16 | |
| 17 | def send_post_request(data: CallGithubData) -> None: |
| 18 | from integrations.github.github import generate_body_comment |
| 19 | |
| 20 | feature_name = data.github_data.feature_name |
| 21 | feature_id = data.github_data.feature_id |
| 22 | project_id = data.github_data.project_id |
| 23 | event_type = data.event_type |
| 24 | feature_states = data.github_data.feature_states or [] |
| 25 | installation_id = data.github_data.installation_id |
| 26 | segment_name = data.github_data.segment_name |
| 27 | body = generate_body_comment( |
| 28 | name=feature_name, |
| 29 | event_type=event_type, |
| 30 | project_id=project_id, |
| 31 | feature_id=feature_id, |
| 32 | feature_states=feature_states, |
| 33 | segment_name=segment_name, |
| 34 | ) |
| 35 | |
| 36 | if ( |
| 37 | event_type == GitHubEventType.FLAG_UPDATED.value |
| 38 | or event_type == GitHubEventType.FLAG_DELETED.value |
| 39 | or event_type == GitHubEventType.FLAG_UPDATED_FROM_GHA.value |
| 40 | ): |
| 41 | for resource in data.feature_external_resources: |
| 42 | url = resource.get("url") |
| 43 | pathname = urlparse(url).path |
| 44 | split_url = pathname.split("/") # type: ignore[arg-type] |
| 45 | post_comment_to_github( |
| 46 | installation_id, |
| 47 | split_url[1], # type: ignore[arg-type] |
| 48 | split_url[2], # type: ignore[arg-type] |
| 49 | split_url[4], # type: ignore[arg-type] |
| 50 | body, |
| 51 | ) |
| 52 | |
| 53 | elif event_type == GitHubEventType.FEATURE_EXTERNAL_RESOURCE_REMOVED.value: |
| 54 | url = data.github_data.url |
| 55 | pathname = urlparse(url).path # type: ignore[assignment] |
| 56 | split_url = pathname.split("/") # type: ignore[arg-type] |
| 57 | post_comment_to_github( |
| 58 | installation_id, |
| 59 | split_url[1], # type: ignore[arg-type] |
| 60 | split_url[2], # type: ignore[arg-type] |
| 61 | split_url[4], # type: ignore[arg-type] |
| 62 | body, |
| 63 | ) |
| 64 | else: |
| 65 | url = data.feature_external_resources[ |
| 66 | len(data.feature_external_resources) - 1 |
| 67 | ].get("url") |
| 68 | pathname = urlparse(url).path |
| 69 | split_url = pathname.split("/") # type: ignore[arg-type] |
| 70 | post_comment_to_github( |
| 71 | installation_id, |
| 72 | split_url[1], # type: ignore[arg-type] |
| 73 | split_url[2], # type: ignore[arg-type] |
| 74 | split_url[4], # type: ignore[arg-type] |
no test coverage detected
searching dependent graphs…