Skip to content

feat: Add path and query params to test-results endpoint #93264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 11, 2025

Conversation

ajay-sentry
Copy link
Contributor

@ajay-sentry ajay-sentry commented Jun 10, 2025

This PR aims to add and uptake a number of path and query parameters for the first codecov endpoint being called in sentry.

First, we're adding both the path parameters:

  • Repository: string
  • Owner: string

Second, we're adding a number of query paramters:

  • sortBy: string
  • filterBy: string
  • interval: string (date)
  • branch: string
  • first: int
  • last: int

If neither first nor last are supplied, the default is 20

You'll notice that for the orderby parameter, sentry opts to use a "-" to denote descending rather than "DESC" like we did on the codecov side, so we had to accommodate for that. Otherwise it's fairly straightforward.

This should also update the openAPI spec accordingly.

Screenshot 2025-06-10 at 3 17 23 PM Screenshot 2025-06-10 at 3 19 06 PM

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@ajay-sentry ajay-sentry requested review from a team as code owners June 10, 2025 19:01
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 10, 2025
Copy link

codecov bot commented Jun 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #93264       +/-   ##
===========================================
+ Coverage   46.19%   87.98%   +41.78%     
===========================================
  Files       10245    10267       +22     
  Lines      591310   592188      +878     
  Branches    23011    23011               
===========================================
+ Hits       273157   521019   +247862     
+ Misses     317663    70679   -246984     
  Partials      490      490               

@ajay-sentry ajay-sentry changed the title feat: Add and uptake branch,interval,sort,order q params and owner/repo path params feat: Add path and query params to test-results endpoint Jun 10, 2025

variables = {
"owner": owner,
"repo": repository,
"filters": {
"branch": branch,
"branch": request.query_params.get("branch", "main"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this work w/ master? I suppose main captures more than master these days

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just pass in a branch name for master, eventually the frontend will be the SOT, we're just defaulting main here so the user doesn't need to pass a branch for most cases


variables = {
"owner": owner,
"repo": repository,
"filters": {
"branch": branch,
"branch": request.query_params.get("branch", "main"),
"parameter": request.query_params.get("sortBy"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this support every column value?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I've seen other tables use sort instead of sortBy, thoughts on changing this? We can also adjust in the frontend, but seems consistent to use sort

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it should!

""",
)
TEST_RESULTS_ORDER_BY = OpenApiParameter(
name="orderBy",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tables I've worked with do sort=-<columnName> (or whatever we choose). Just double checking if this is the behaviour you'd expect here, since we don't explicitly seem to provide an orderBy param, the backend seems to infer it from the sort value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just updated, thanks for the catch

Comment on lines 94 to 100
if not first and not last:
first = 20
if first and last:
return Response(
status=status.HTTP_400_BAD_REQUEST,
data={"details": "Cannot specify both `first` and `last`"},
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we switch these two if statements' ordering? Since the first one can modify first's value, i think it's more clear the other way around.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do!

joseph-sentry added a commit that referenced this pull request Jun 11, 2025
This commit adds support for the interval query parameter to the TestResultsAggregates endpoint.
Adds a new test to verify the interval parameter is correctly passed to the Codecov client.
Fixes an existing test that had an incorrect assertion for git_provider_org.
Resolves a linter conflict by renaming the endpoint attribute to endpoint_name in the test class to avoid overriding a base class property.

Depends on: #93264
joseph-sentry added a commit that referenced this pull request Jun 11, 2025
This commit adds support for the interval query parameter to the
TestResultsAggregates endpoint.

Depends on: #93264
Copy link
Contributor

@joseph-sentry joseph-sentry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm just one quick comment`


variables = {
"owner": owner,
"repo": repository,
"filters": {
"branch": branch,
"branch": request.query_params.get("branch", "main"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, i would think that there's no fallback for branch unless we're just keeping this here for the time that this will be under development

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's right, just keeping it for development. We can remove as soon as query params are hooked up

@ajay-sentry ajay-sentry merged commit 2b2767a into master Jun 11, 2025
61 of 62 checks passed
@ajay-sentry ajay-sentry deleted the Ajay/test-results-q-params branch June 11, 2025 15:39
joseph-sentry added a commit that referenced this pull request Jun 11, 2025
This commit adds support for the interval query parameter to the
TestResultsAggregates endpoint.

Depends on: #93264
joseph-sentry added a commit that referenced this pull request Jun 11, 2025
…93331)

This commit adds support for the interval query parameter to the
TestResultsAggregates endpoint.

Depends on: #93264
vishnupsatish pushed a commit that referenced this pull request Jun 12, 2025
This PR aims to add and uptake a number of path and query parameters for
the first codecov endpoint being called in sentry.

First, we're adding both the path parameters:
- Repository: string
- Owner: string

Second, we're adding a number of query paramters:
- sortBy: string
- filterBy: string
- interval: string (date)
- branch: string
- first: int
- last: int

If neither first nor last are supplied, the default is 20

You'll notice that for the orderby parameter, sentry opts to use a "-"
to denote descending rather than "DESC" like we did on the codecov side,
so we had to accommodate for that. Otherwise it's fairly
straightforward.

This should also update the openAPI spec accordingly.

<img width="665" alt="Screenshot 2025-06-10 at 3 17 23 PM"
src="https://github.com/user-attachments/assets/5135883e-df48-4121-a07e-8cf2e9b650a0"
/>

<img width="690" alt="Screenshot 2025-06-10 at 3 19 06 PM"
src="https://github.com/user-attachments/assets/e738413c-b70f-4303-804f-9eb50e6c008a"
/>



<!--

  Sentry employees and contractors can delete or ignore the following.

-->

### Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated
in the State of Delaware in 2015 as Functional Software, Inc. and is
gonna need some rights from me in order to utilize my contributions in
this here PR. So here's the deal: I retain all rights, title and
interest in and to my contributions, and by keeping this boilerplate
intact I confirm that Sentry can use, modify, copy, and redistribute my
contributions, under Sentry's choice of terms.
vishnupsatish pushed a commit that referenced this pull request Jun 12, 2025
…93331)

This commit adds support for the interval query parameter to the
TestResultsAggregates endpoint.

Depends on: #93264
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants