ajuste na pesquisa de informacao, para passar a dar prioridade

This commit is contained in:
2026-11-13 12:07:51 +02:00
parent 71f2fcbb84
commit eab09dd61e
4 changed files with 52 additions and 7 deletions
@@ -29,8 +29,7 @@ class GlobalSearchController extends Controller
if ($tokens !== []) {
$factories = [
'Páginas e serviços' => function () use ($search, $tokens, $term) {
$pages = array_values(array_filter($this->pages(), fn ($page) => $search->matches(implode(' ', $page), $tokens)
&& $search->score($page['title'], $term, $tokens) > 0));
$pages = array_values(array_filter($this->pages(), fn ($page) => $search->matches(implode(' ', $page), $tokens)));
usort($pages, fn ($a, $b) => $search->score($b['title'], $term, $tokens) <=> $search->score($a['title'], $term, $tokens)
?: strcmp($a['title'], $b['title']) ?: strcmp($a['url'], $b['url']));