Expose which search strategy produced each result

query_packages now assigns @search_sources - a hash mapping package
ids to the matching strategy that put them into the results: :exact,
:name_prefix, :name_contains, :semantic or :fulltext. The grid and
list views render a small badge with a humanized label per result,
making the search tiers observable. semantic_results() was folded
into search_packages() so each branch tags its own source. Adds the
rails-controller-testing gem for assigns() in tests.
This commit is contained in:
Christoph Haas 2026-08-23 10:39:50 +02:00
parent 61b64fae25
commit 323b7004ed
6 changed files with 69 additions and 24 deletions

View file

@ -1,4 +1,16 @@
module PackagesHelper
# Human readable label for the search strategy that put a package
# into the search results (see PackagesController#search_packages)
def search_source_label(source)
{
exact: 'exact match',
name_prefix: 'name match',
name_contains: 'name match',
semantic: 'similar',
fulltext: 'full-text'
}[source]
end
# Return the description and/or the version of the package
def screenshot_caption(screenshot)
str = []