diff --git a/bauh/core/controller.py b/bauh/core/controller.py index a7df684d..55283474 100755 --- a/bauh/core/controller.py +++ b/bauh/core/controller.py @@ -5,9 +5,9 @@ from typing import List, Set, Type from bauh_api.abstract.controller import SoftwareManager, SearchResult, ApplicationContext from bauh_api.abstract.disk import DiskCacheLoader 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): @@ -254,9 +254,12 @@ class GenericSoftwareManager(SoftwareManager): man_sugs = man.list_suggestions(limit) if man_sugs: + if len(man_sugs) > limit: + man_sugs = man_sugs[0:limit] + suggestions.extend(man_sugs) - def list_suggestions(self, limit: int) -> List[SoftwarePackage]: + def list_suggestions(self, limit: int) -> List[PackageSuggestion]: if self.managers: suggestions, threads = [], [] for man in self.managers: @@ -267,4 +270,7 @@ class GenericSoftwareManager(SoftwareManager): for t in threads: t.join() + if suggestions: + suggestions.sort(key=lambda s: s.priority.value, reverse=True) + return suggestions diff --git a/bauh/view/qt/thread.py b/bauh/view/qt/thread.py index aba715b3..fac21dff 100644 --- a/bauh/view/qt/thread.py +++ b/bauh/view/qt/thread.py @@ -385,7 +385,7 @@ class FindSuggestions(AsyncAction): def run(self): 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):