mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
improving search response 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.5.1]
|
||||
### Improvements:
|
||||
- suggestions are now retrieved asynchronously. Response time takes 45% less.
|
||||
- search response time takes an average of 20% less ( reaching 35% for several results )
|
||||
### Fixes:
|
||||
- [flatpak dependency](https://github.com/vinifmor/fpakman/issues/36)
|
||||
|
||||
|
||||
@@ -138,21 +138,28 @@ class GenericApplicationManager(ApplicationManager):
|
||||
else:
|
||||
return man.is_enabled()
|
||||
|
||||
def _search(self, word: str, man: ApplicationManager, disk_loader, res: dict):
|
||||
if self._is_enabled(man):
|
||||
apps_found = man.search(word=word, disk_loader=disk_loader)
|
||||
res['installed'].extend(apps_found['installed'])
|
||||
res['new'].extend(apps_found['new'])
|
||||
|
||||
def search(self, word: str, disk_loader: DiskCacheLoader = None) -> Dict[str, List[Application]]:
|
||||
res = {'installed': [], 'new': []}
|
||||
|
||||
norm_word = word.strip().lower()
|
||||
disk_loader = None
|
||||
disk_loader = self.disk_loader_factory.new()
|
||||
disk_loader.start()
|
||||
|
||||
threads = []
|
||||
|
||||
for man in self.managers:
|
||||
if self._is_enabled(man):
|
||||
if not disk_loader:
|
||||
disk_loader = self.disk_loader_factory.new()
|
||||
disk_loader.start()
|
||||
t = Thread(target=self._search, args=(norm_word, man, disk_loader, res))
|
||||
t.start()
|
||||
threads.append(t)
|
||||
|
||||
apps_found = man.search(word=norm_word, disk_loader=disk_loader)
|
||||
res['installed'].extend(apps_found['installed'])
|
||||
res['new'].extend(apps_found['new'])
|
||||
for t in threads:
|
||||
t.join()
|
||||
|
||||
if disk_loader:
|
||||
disk_loader.stop = True
|
||||
|
||||
Reference in New Issue
Block a user