Skip to content

Commit

Permalink
Only include indexed rubygems in /names (#4475)
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins authored Feb 21, 2024
1 parent 5e60ce9 commit 330c14f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/gem_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def self.ordered_names(cached: true)
StatsD.increment "compact_index.memcached.names.hit"
else
StatsD.increment "compact_index.memcached.names.miss"
names = Rubygem.order("name").pluck("name")
names = Rubygem.with_versions.order("name").pluck("name")
Rails.cache.write("names", names)
end
names
Expand Down
4 changes: 2 additions & 2 deletions test/integration/api/compact_index_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def digest(body)

# another gem
rubygem = create(:rubygem, name: "gemA")
dep1 = create(:rubygem, name: "gemA1")
dep2 = create(:rubygem, name: "gemA2")
dep1 = create(:rubygem, name: "gemA1", indexed: true)
dep2 = create(:rubygem, name: "gemA2", indexed: true)

# minimal version
create(:version,
Expand Down
4 changes: 3 additions & 1 deletion test/models/gem_info_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ class GemInfoTest < ActiveSupport::TestCase

context ".ordered_names" do
setup do
%w[abc bcd abd].each { |name| create(:rubygem, name: name) }
%w[abc bcd abd].each { |name| create(:rubygem, name:, indexed: true) }

create(:rubygem, name: "abe", indexed: false)

@ordered_names = %w[abc abd bcd]
end
Expand Down

0 comments on commit 330c14f

Please sign in to comment.