Skip to content
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

move release commits endpoint to organization path #4863

Merged
merged 4 commits into from Mar 10, 2017

Conversation

macqueen
Copy link
Contributor

@macqueen macqueen commented Feb 3, 2017

moves https://docs.sentry.io/api/releases/get-release-commits/

depends on #4775. tests will fail until that can be merged/rebased in because i need OrganizationReleasesBaseEndpoint from that pr.

cc @benvinegar @ckj

@getsentry-bot
Copy link
Contributor

getsentry-bot commented Feb 3, 2017

1 Warning
⚠️ Changes require @getsentry/security sign-off

Security concerns found

  • src/sentry/api/endpoints/organization_release_commits.py
  • src/sentry/api/endpoints/project_release_commits.py
  • src/sentry/api/endpoints/release_commits.py

Generated by 🚫 danger

@macqueen macqueen force-pushed the org-release-commits-endpoint branch from 24cd030 to 123d533 Compare March 9, 2017 23:09
CHANGES Outdated
@@ -16,6 +16,7 @@ Schema Changes
~~~~~~~~~~~~~~

- Added ``Deploy`` model
- Added OrganizationReleaseCommitsEndpoint
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an API change.

request=request,
queryset=queryset,
order_by='order',
on_results=lambda x: serialize([rc.commit for rc in x], request.user),
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're only serializing the Commit objects instead of the ReleaseCommit, why don't we just query for Commits instead? Seems a bit awkward going through ReleaseCommit just to get that.

You could just do:

Commit.objects.filter(releasecommit__release=release)

And you'll directly have the objects you want. Then the order_by becomes releasecommit__order.

This gives us SQL like:

SELECT "sentry_commit"."id", "sentry_commit"."organization_id", "sentry_commit"."repository_id", "sentry_commit"."key", "sentry_commit"."date_added", "sentry_commit"."author_id", "sentry_commit"."message"
FROM "sentry_commit"
INNER JOIN "sentry_releasecommit" ON (
  "sentry_commit"."id" = "sentry_releasecommit"."commit_id"
)
WHERE "sentry_releasecommit"."release_id" = 1 
ORDER BY "sentry_releasecommit"."order" ASC

Unless I'm missing something here with what you're doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i just did it this way because that's how we were doing it in the project version of this endpoint (see below file). but i can change it in both places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, so that doesn't work because of https://github.com/getsentry/sentry/blob/master/src/sentry/api/paginator.py#L120

like Commit.objects.filter(releasecommit__release=release).order_by('releasecommit__order') works, but the paginator tries to do commit.releasecommit__order which doesn't.

Copy link
Contributor

Choose a reason for hiding this comment

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

welp 😢

@macqueen macqueen merged commit 1095817 into master Mar 10, 2017
@macqueen macqueen deleted the org-release-commits-endpoint branch March 10, 2017 21:00
@github-actions github-actions bot locked and limited conversation to collaborators Dec 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants