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

@ -24,6 +24,9 @@
= pkg.name
.text
= pkg.description
- if @search_sources[pkg.id]
.text.search-source
span.label.secondary = search_source_label(@search_sources[pkg.id])
- elsif @view_style==:list
- @packages.to_a.each do |pkg|
.grid-x.grid-margin-x.listview
@ -37,6 +40,9 @@
a href=package_path(name: pkg.name)
=pkg.name
p =pkg.description
- if @search_sources[pkg.id]
p
span.label.secondary = search_source_label(@search_sources[pkg.id])
.listview.longdescription
= pkg.long_description_first_paragraph