mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 10:34:15 +02:00
implementing new suggestions api
This commit is contained in:
@@ -5,9 +5,9 @@ from typing import List, Set, Type
|
|||||||
from bauh_api.abstract.controller import SoftwareManager, SearchResult, ApplicationContext
|
from bauh_api.abstract.controller import SoftwareManager, SearchResult, ApplicationContext
|
||||||
from bauh_api.abstract.disk import DiskCacheLoader
|
from bauh_api.abstract.disk import DiskCacheLoader
|
||||||
from bauh_api.abstract.handler import ProcessWatcher
|
from bauh_api.abstract.handler import ProcessWatcher
|
||||||
from bauh_api.abstract.model import SoftwarePackage, PackageUpdate, PackageHistory
|
from bauh_api.abstract.model import SoftwarePackage, PackageUpdate, PackageHistory, PackageSuggestion
|
||||||
|
|
||||||
SUGGESTIONS_LIMIT = 6
|
SUGGESTIONS_LIMIT = 5
|
||||||
|
|
||||||
|
|
||||||
class GenericSoftwareManager(SoftwareManager):
|
class GenericSoftwareManager(SoftwareManager):
|
||||||
@@ -254,9 +254,12 @@ class GenericSoftwareManager(SoftwareManager):
|
|||||||
man_sugs = man.list_suggestions(limit)
|
man_sugs = man.list_suggestions(limit)
|
||||||
|
|
||||||
if man_sugs:
|
if man_sugs:
|
||||||
|
if len(man_sugs) > limit:
|
||||||
|
man_sugs = man_sugs[0:limit]
|
||||||
|
|
||||||
suggestions.extend(man_sugs)
|
suggestions.extend(man_sugs)
|
||||||
|
|
||||||
def list_suggestions(self, limit: int) -> List[SoftwarePackage]:
|
def list_suggestions(self, limit: int) -> List[PackageSuggestion]:
|
||||||
if self.managers:
|
if self.managers:
|
||||||
suggestions, threads = [], []
|
suggestions, threads = [], []
|
||||||
for man in self.managers:
|
for man in self.managers:
|
||||||
@@ -267,4 +270,7 @@ class GenericSoftwareManager(SoftwareManager):
|
|||||||
for t in threads:
|
for t in threads:
|
||||||
t.join()
|
t.join()
|
||||||
|
|
||||||
|
if suggestions:
|
||||||
|
suggestions.sort(key=lambda s: s.priority.value, reverse=True)
|
||||||
|
|
||||||
return suggestions
|
return suggestions
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ class FindSuggestions(AsyncAction):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
sugs = self.man.list_suggestions(limit=-1)
|
sugs = self.man.list_suggestions(limit=-1)
|
||||||
self.notify_finished(sugs if sugs is not None else [])
|
self.notify_finished([s.package for s in sugs] if sugs is not None else [])
|
||||||
|
|
||||||
|
|
||||||
class ListWarnings(QThread):
|
class ListWarnings(QThread):
|
||||||
|
|||||||
Reference in New Issue
Block a user