fix: fix search result sorting based if there is exact match or

starts with (closes #152)
This commit is contained in:
2025-07-14 01:12:27 +03:00
parent 9217c8c759
commit f5aec4e5c1

View File

@ -70,7 +70,11 @@ class SearchView(BaseView):
if not packages:
raise HTTPNotFound(reason=f"No packages found for terms: {search}")
comparator: Callable[[AURPackage], str] = lambda item: item.package_base
comparator: Callable[[AURPackage], tuple[bool, bool, str]] = lambda item: (
item.package_base not in search, # inverted because False < True
not any(item.package_base.startswith(term) for term in search), # same as above
item.package_base,
)
response = [
{
"package": package.package_base,