mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-15 15:05:48 +00:00
fix: fix search result sorting based if there is exact match or
starts with (closes #152)
This commit is contained in:
@ -70,7 +70,11 @@ class SearchView(BaseView):
|
|||||||
if not packages:
|
if not packages:
|
||||||
raise HTTPNotFound(reason=f"No packages found for terms: {search}")
|
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 = [
|
response = [
|
||||||
{
|
{
|
||||||
"package": package.package_base,
|
"package": package.package_base,
|
||||||
|
Reference in New Issue
Block a user