feat: add endpoint to list only issues that have PRs created from Seer Explorer#107850
feat: add endpoint to list only issues that have PRs created from Seer Explorer#107850
Conversation
|
🚨 Warning: This pull request contains Frontend and Backend changes! It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently. Have questions? Please ask in the |
e2a828c to
5764824
Compare
559ac54 to
148a6a8
Compare
| Get a list of issues that have a PR created from Seer Explorer | ||
|
|
||
| Query Parameters: | ||
| None |
There was a problem hiding this comment.
I may add one to filter for current user only, not sure yet
There was a problem hiding this comment.
nit - could maybe pass in the category_key + value?
There was a problem hiding this comment.
@aliu39 I can take a look as a follow-up. when Seer Explorer creates a PR outside of an issue, is category_key still autofix? (trying to better understand how cat key/value is used)
There was a problem hiding this comment.
yeah PRs created by the floating explorer chat have category_key = None. categ is set on SeerExplorerClient init and that's saved to the ExplorerState + DbExplorerRun in seer
if ppl make more explorer-based features in the future, they can set other categs on their client
| limit: int | None = None, | ||
| ) -> list[ExplorerRun]: | ||
| expand: Literal["prs"] | None = None, | ||
| only_current_user: bool = True, |
There was a problem hiding this comment.
/explorer-runs/ requires that it filters for current user only.
src/sentry/seer/endpoints/organization_seer_explorer_pr_groups.py
Outdated
Show resolved
Hide resolved
src/sentry/seer/endpoints/organization_seer_explorer_pr_groups.py
Outdated
Show resolved
Hide resolved
src/sentry/seer/endpoints/organization_seer_explorer_pr_groups.py
Outdated
Show resolved
Hide resolved
src/sentry/seer/endpoints/organization_seer_explorer_pr_groups.py
Outdated
Show resolved
Hide resolved
Rename endpoint, client method, URL path, and test file: - OrganizationExplorerIssuesWithPRs -> OrganizationSeerExplorerPRGroups - get_issues_with_prs() -> get_pr_summaries() - /seer/explorer-prs/ -> /seer/explorer-pr-groups/ - Seer API: runs/with-prs -> pr-summaries - Fix missing user_id in test fixture helper
…ps endpoint Remove per-group dedup so all runs are returned. Allow group to be None when group_id is missing or unresolvable, and capture_message to Sentry at warning level in those cases.
cf2ef59 to
77cd597
Compare
armcknight
left a comment
There was a problem hiding this comment.
Mostly questions from reading the tests, as that is where I think my review is best left 😄
tests/sentry/seer/endpoints/test_organization_seer_explorer_pr_groups.py
Show resolved
Hide resolved
| pr_states = response.json()["data"][0]["repoPrStates"] | ||
| assert pr_states["getsentry/sentry"]["repoName"] == "getsentry/sentry" | ||
| assert pr_states["getsentry/sentry"]["branchName"] is None | ||
| assert pr_states["getsentry/sentry"]["prNumber"] is None | ||
| assert pr_states["getsentry/sentry"]["prUrl"] is None | ||
| assert pr_states["getsentry/sentry"]["prCreationStatus"] is None |
There was a problem hiding this comment.
Are there real life examples where we have a PR linked to an issue but none of this information? Or am I misunderstanding the test case?
There was a problem hiding this comment.
No I think this is just based on the typing of repo_pr_states
| def test_get_no_matching_groups_returns_null_group(self) -> None: | ||
| """When Seer returns group IDs that don't exist in the requested project, group is None.""" | ||
| self.mock_client.get_runs.return_value = [self._make_seer_item(group_id=999999)] | ||
|
|
||
| response = self.client.get(self.url + f"?project={self.project.id}") | ||
|
|
||
| assert response.status_code == 200 | ||
| data = response.json()["data"] | ||
| assert len(data) == 1 | ||
| assert data[0]["group"] is None | ||
|
|
||
| def test_get_includes_null_group_id_runs(self) -> None: | ||
| """Runs without a group_id are included with group=None.""" | ||
| group = self.create_group(project=self.project) | ||
|
|
||
| self.mock_client.get_runs.return_value = [ | ||
| self._make_seer_item(group_id=group.id, run_id=1), | ||
| self._make_seer_item(group_id=None, run_id=2), | ||
| ] | ||
| self.mock_serialize.return_value = [{"id": str(group.id), "title": "Issue 1"}] | ||
|
|
||
| response = self.client.get(self.url + f"?project={self.project.id}") | ||
|
|
||
| assert response.status_code == 200 | ||
| data = response.json()["data"] | ||
| assert len(data) == 2 | ||
| assert data[0]["group"]["id"] == str(group.id) | ||
| assert data[1]["group"] is None |
There was a problem hiding this comment.
I don't know what group None implies, w.r.t. the native clients. Is this a response state we need to worry about, or is this just internal server logic? Looking at the client implementation, we only have this in one place, SentryIssueSummary.groupId, which is not an optional attribute, so we wouldn't be able to handle None if it came down in a response.
There was a problem hiding this comment.
For native clients, we probably want to handle this case -- we can make Seer Explore runs that generate PRs that are not bound to an Issue.
There was a problem hiding this comment.
hmm interesting. i guess let's see what happens, would be easy enough to fix in the clients 👍🏻
| Get a list of issues that have a PR created from Seer Explorer | ||
|
|
||
| Query Parameters: | ||
| None |
There was a problem hiding this comment.
nit - could maybe pass in the category_key + value?
This exposes the endpoint on Seer and joins the results from Seer with serialized groups.
This will be used internally only for now for our macos app.