mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
improved: search results sorting time
This commit is contained in:
@@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
## [0.4.3]
|
## [0.4.3]
|
||||||
### Improvements
|
### Improvements
|
||||||
- new environment variable / argument to enable / disable the tray icon and update-check daemon: FPAKMAN_TRAY (--tray)
|
- new environment variable / argument to enable / disable the tray icon and update-check daemon: FPAKMAN_TRAY (--tray)
|
||||||
|
- search results sorting takes an average of 35% less time, reaching 60% in some scenarios
|
||||||
### Fixes:
|
### Fixes:
|
||||||
- replacing default app icons by null icons
|
- replacing default app icons by null icons
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import time
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
from typing import List, Dict
|
from typing import List, Dict
|
||||||
@@ -101,8 +102,7 @@ class GenericApplicationManager(ApplicationManager):
|
|||||||
self.prepare()
|
self.prepare()
|
||||||
|
|
||||||
def _sort(self, apps: List[Application], word: str) -> List[Application]:
|
def _sort(self, apps: List[Application], word: str) -> List[Application]:
|
||||||
|
exact_name_matches, contains_name_matches, others = [], [], []
|
||||||
exact_name_matches, contains_name_matches, desc_name_matches, others = [], [], [], []
|
|
||||||
|
|
||||||
for app in apps:
|
for app in apps:
|
||||||
lower_name = app.base_data.name.lower()
|
lower_name = app.base_data.name.lower()
|
||||||
@@ -111,13 +111,11 @@ class GenericApplicationManager(ApplicationManager):
|
|||||||
exact_name_matches.append(app)
|
exact_name_matches.append(app)
|
||||||
elif word in lower_name:
|
elif word in lower_name:
|
||||||
contains_name_matches.append(app)
|
contains_name_matches.append(app)
|
||||||
elif app.base_data.description and word in app.base_data.description.lower():
|
|
||||||
desc_name_matches.append(app)
|
|
||||||
else:
|
else:
|
||||||
others.append(app)
|
others.append(app)
|
||||||
|
|
||||||
res = []
|
res = []
|
||||||
for app_list in (exact_name_matches, contains_name_matches, desc_name_matches, others):
|
for app_list in (exact_name_matches, contains_name_matches, others):
|
||||||
app_list.sort(key=lambda a: a.base_data.name.lower())
|
app_list.sort(key=lambda a: a.base_data.name.lower())
|
||||||
res.extend(app_list)
|
res.extend(app_list)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user