-
-
Notifications
You must be signed in to change notification settings - Fork 974
Include role in owners api response #5821
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
base: master
Are you sure you want to change the base?
Include role in owners api response #5821
Conversation
|
Hello, you're right there is no pattern established to compose payload so it is in-lined usually. rubygems.org/app/controllers/api/v1/activities_controller.rb Lines 14 to 17 in 9bcbf60
rubygems.org/app/controllers/api/v2/contents_controller.rb Lines 30 to 34 in 9bcbf60
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5821 +/- ##
==========================================
- Coverage 97.19% 94.44% -2.76%
==========================================
Files 471 471
Lines 9691 9753 +62
==========================================
- Hits 9419 9211 -208
- Misses 272 542 +270 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| rescue_from ActiveRecord::RecordNotFound, with: :render_not_found | ||
|
|
||
| def show | ||
| payload = @rubygem.owners.map { |owner| owner.payload.merge("role" => owner.ownerships.find_by(rubygem: @rubygem).role) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to make this more SQL effective. Now it seems to trigger additional query per each owner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @simi
I believe my latest commit reduces it back down to one query
Addresses #5816 by including the role of each member of a gem in the response to /api/v1/gems/:gem_id/owners.json
Note: There could be a better solution to this, but I found it difficult to work around the User#payload method. It looks like using serializers was discussed in the past but rejected. #1027 (comment) As this is my first PR here, I am absolutely open to feedback or better approaches.