Skip to content

Fix reverse dependencies by using distinct #5566

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

federicoaldunate
Copy link

Fix reverse dependencies bug

Another example: https://rubygems.org/gems/rspec/reverse_dependencies

Description

Reverse dependencies are being repeated.
Linked issue: #5199

Tried to solve this at least in the user facing controller side of things.

Copy link

codecov bot commented Mar 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.35%. Comparing base (b827011) to head (a1c473f).
Report is 12 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #5566       +/-   ##
===========================================
+ Coverage   71.71%   94.35%   +22.63%     
===========================================
  Files         453      453               
  Lines        9609     9470      -139     
===========================================
+ Hits         6891     8935     +2044     
+ Misses       2718      535     -2183     

☔ 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.

@segiddins
Copy link
Member

I'm a bit concerned if this will have a performance impact, can you share the generated queries and I can explain analyze them?

@simi
Copy link
Member

simi commented Mar 31, 2025

I'm a bit concerned if this will have a performance impact, can you share the generated queries and I can explain analyze them?

I'll check.

@federicoaldunate federicoaldunate force-pushed the fix-repetead-reverse-depenencies branch from a1c473f to d7c46a8 Compare April 6, 2025 04:25
@federicoaldunate
Copy link
Author

I'm a bit concerned if this will have a performance impact, can you share the generated queries and I can explain analyze them?
I don't think it will have a big impact, this is the difference between the queries generated:
Before

SELECT rubygems.*
FROM rubygems
JOIN versions
  ON rubygems.id = versions.rubygem_id
JOIN dependencies
  ON versions.id = dependencies.version_id
JOIN gem_downloads
  ON gem_downloads.version_id = 0
 AND gem_downloads.rubygem_id = rubygems.id
WHERE dependencies.rubygem_id = {the_ruby_gem_id}
  AND versions.indexed = TRUE
  AND versions.position = 0
ORDER BY gem_downloads.count DESC;

After

SELECT DISTINCT rubygems.*, gem_downloads.count
FROM rubygems
JOIN versions
  ON rubygems.id = versions.rubygem_id
JOIN dependencies
  ON versions.id = dependencies.version_id
JOIN gem_downloads
  ON gem_downloads.version_id = 0
 AND gem_downloads.rubygem_id = rubygems.id
WHERE dependencies.rubygem_id = {the_ruby_gem_id}
  AND versions.indexed = TRUE
  AND versions.position = 0
ORDER BY gem_downloads.count DESC;

@federicoaldunate
Copy link
Author

@simi @segiddins, let me know what you think.

@federicoaldunate federicoaldunate requested a review from simi April 10, 2025 14:06
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.

3 participants