mirror of
				https://github.com/arcan1s/ahriman.git
				synced 2025-11-02 23:03:41 +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:
 | 
			
		||||
            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,
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user