mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 02:24:16 +02:00
[appimage] suggestions
This commit is contained in:
@@ -17,7 +17,7 @@ from bauh.api.abstract.view import MessageType
|
|||||||
from bauh.api.constants import HOME_PATH
|
from bauh.api.constants import HOME_PATH
|
||||||
from bauh.commons.html import bold
|
from bauh.commons.html import bold
|
||||||
from bauh.commons.system import SystemProcess, new_subprocess, ProcessHandler, run_cmd
|
from bauh.commons.system import SystemProcess, new_subprocess, ProcessHandler, run_cmd
|
||||||
from bauh.gems.appimage import query, INSTALLATION_PATH
|
from bauh.gems.appimage import query, INSTALLATION_PATH, suggestions
|
||||||
from bauh.gems.appimage.model import AppImage
|
from bauh.gems.appimage.model import AppImage
|
||||||
from bauh.gems.appimage.worker import DatabaseUpdater
|
from bauh.gems.appimage.worker import DatabaseUpdater
|
||||||
|
|
||||||
@@ -367,7 +367,28 @@ class AppImageManager(SoftwareManager):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def list_suggestions(self, limit: int) -> List[PackageSuggestion]:
|
def list_suggestions(self, limit: int) -> List[PackageSuggestion]:
|
||||||
pass
|
res = []
|
||||||
|
|
||||||
|
connection = self._get_db_connection(DB_APPS_PATH)
|
||||||
|
|
||||||
|
if connection:
|
||||||
|
try:
|
||||||
|
sugs = [(i, p) for i, p in suggestions.ALL.items()]
|
||||||
|
sugs.sort(key=lambda t: t[1].value, reverse=True)
|
||||||
|
|
||||||
|
if limit > 0:
|
||||||
|
sugs = sugs[0:limit]
|
||||||
|
|
||||||
|
cursor = connection.cursor()
|
||||||
|
cursor.execute(query.FIND_APPS_BY_NAME_FULL.format(','.join(["'{}'".format(s[0]) for s in sugs])))
|
||||||
|
|
||||||
|
for t in cursor.fetchall():
|
||||||
|
app = AppImage(*t)
|
||||||
|
res.append(PackageSuggestion(app, suggestions.ALL.get(app.name.lower())))
|
||||||
|
finally:
|
||||||
|
connection.close()
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
def is_default_enabled(self) -> bool:
|
def is_default_enabled(self) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ RELEASE_ATTRS = ('version', 'url_download', 'published_at')
|
|||||||
SEARCH_APPS_BY_NAME_OR_DESCRIPTION = "SELECT {} FROM apps".format(','.join(APP_ATTRS)) + " WHERE lower(name) LIKE '%{}%' or lower(description) LIKE '%{}%'"
|
SEARCH_APPS_BY_NAME_OR_DESCRIPTION = "SELECT {} FROM apps".format(','.join(APP_ATTRS)) + " WHERE lower(name) LIKE '%{}%' or lower(description) LIKE '%{}%'"
|
||||||
FIND_APP_ID_BY_NAME_AND_GITHUB = "SELECT id FROM apps WHERE lower(name) = '{}' and lower(github) = '{}'"
|
FIND_APP_ID_BY_NAME_AND_GITHUB = "SELECT id FROM apps WHERE lower(name) = '{}' and lower(github) = '{}'"
|
||||||
FIND_APPS_BY_NAME = "SELECT name, github, version, url_download FROM apps WHERE lower(name) IN ({})"
|
FIND_APPS_BY_NAME = "SELECT name, github, version, url_download FROM apps WHERE lower(name) IN ({})"
|
||||||
|
FIND_APPS_BY_NAME_FULL = "SELECT {} FROM apps".format(','.join(APP_ATTRS)) + " WHERE lower(name) IN ({})"
|
||||||
FIND_RELEASES_BY_APP_ID = "SELECT {} FROM releases".format(','.join(RELEASE_ATTRS)) + " WHERE app_id = {} ORDER BY version desc"
|
FIND_RELEASES_BY_APP_ID = "SELECT {} FROM releases".format(','.join(RELEASE_ATTRS)) + " WHERE app_id = {} ORDER BY version desc"
|
||||||
|
|||||||
11
bauh/gems/appimage/suggestions.py
Normal file
11
bauh/gems/appimage/suggestions.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from bauh.api.abstract.model import SuggestionPriority
|
||||||
|
|
||||||
|
ALL = {
|
||||||
|
'gamehub': SuggestionPriority.HIGH,
|
||||||
|
'rpcs3': SuggestionPriority.HIGH,
|
||||||
|
'postman': SuggestionPriority.MEDIUM,
|
||||||
|
'etcher': SuggestionPriority.MEDIUM,
|
||||||
|
'nosqlbooster': SuggestionPriority.LOW,
|
||||||
|
'emcas': SuggestionPriority.LOW,
|
||||||
|
'azpianter': SuggestionPriority.LOW
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user