Skip to content

Conversation

@jakebills1
Copy link

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.

@simi
Copy link
Contributor

simi commented Jul 19, 2025

Hello, you're right there is no pattern established to compose payload so it is in-lined usually.

def render_rubygems(versions)
rubygems = versions.includes(:dependencies, :gem_download, rubygem: %i[linkset gem_download]).map do |version|
version.rubygem.payload(version)
end

def checksums_payload(checksums_file)
ShasumFormat.parse(checksums_file).transform_values do |checksum|
{ VersionManifest::DEFAULT_DIGEST => checksum }
end
end

@codecov
Copy link

codecov bot commented Jul 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.44%. Comparing base (874ec61) to head (db4d209).
Report is 2 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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) }
Copy link
Contributor

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.

Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants