summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2023-03-24 15:24:19 +0100
committerYorhel <git@yorhel.nl>2023-03-24 15:24:19 +0100
commit82e5aaf50bdbe2888b64cbd89b34b41f3bd18935 (patch)
treefbbf9d5cabcba7b73a92d80d120447484adecfa2
parent0b2e8201a49a25f8635cee5cd6ccf66387a4b849 (diff)
VN::List: Add exact-match search for other DB entry types
-rw-r--r--lib/VNWeb/VN/List.pm25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/VNWeb/VN/List.pm b/lib/VNWeb/VN/List.pm
index 81b55585..edd941c8 100644
--- a/lib/VNWeb/VN/List.pm
+++ b/lib/VNWeb/VN/List.pm
@@ -410,7 +410,20 @@ TUWF::get qr{/v(?:/(?<char>all|[a-z0]))?}, sub {
) : [];
} || (($count, $list) = (undef, []));
- return tuwf->resRedirect("/$list->[0]{id}") if $count && $count == 1 && $opt->{q} && !defined $opt->{ch};
+ my $fullq = join '', $opt->{q}->words->@*;
+ my $other = length $fullq && $opt->{s}->sorted('qscore') && $opt->{p} == 1 ? tuwf->dbAlli("
+ SELECT x.id, i.title
+ FROM (
+ SELECT DISTINCT id
+ FROM search_cache
+ WHERE NOT (id BETWEEN 'v1' AND vndbid_max('v'))
+ AND NOT (id BETWEEN 'r1' AND vndbid_max('r'))
+ AND label =", \$fullq, ') x,
+ ', item_info('id', 'null'), 'i
+ ORDER BY vndbid_type(x.id) DESC, i.title[1+1]
+ ') : [];
+
+ return tuwf->resRedirect("/$list->[0]{id}") if $count && $count == 1 && $opt->{q} && !defined $opt->{ch} && !@$other;
enrich_listing(1, $opt, $list);
$time = time - $time;
@@ -428,6 +441,16 @@ TUWF::get qr{/v(?:/(?<char>all|[a-z0]))?}, sub {
$opt->{f}->elm_;
advsearch_msg_ $count, $time;
};
+ div_ class => 'mainbox', sub {
+ h1_ 'Did you mean to search for...';
+ ul_ style => 'column-width: 250px', sub {
+ li_ sub {
+ b_ {qw/r Release p Producer c Character s Staff g Tag i Trait/}->{substr $_->{id}, 0, 1};
+ txt_ ': ';
+ a_ href => "/$_->{id}", tattr $_;
+ } for @$other;
+ };
+ } if @$other;
listing_ $opt, $list, $count if $count;
};
};