Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow listing of other app types #4308

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def get_eol_message_appid(


@router.get("/appstream", tags=["app"])
def list_appstream() -> list[str]:
return sorted(apps.get_appids())
def list_appstream(filter: apps.AppType = apps.AppType.APPS) -> list[str]:
return sorted(apps.get_appids(filter))


def get_translation(
Expand Down
22 changes: 18 additions & 4 deletions backend/app/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import re
from enum import Enum

import gi

Expand All @@ -12,6 +13,12 @@
all_main_categories = schemas.get_main_categories()


class AppType(str, Enum):
APPS = "apps"
EXTENSION = "extension"
RUNTIME = "runtime"


def add_to_search(app_id: str, app: dict, apps_locale: dict) -> dict:
search_description = re.sub(clean_html_re, "", app["description"])

Expand Down Expand Up @@ -171,14 +178,21 @@ def load_appstream(sqldb) -> None:
p.execute()


def get_appids() -> list[str]:
def get_appids(type: AppType = AppType.APPS) -> list[str]:
filter = None

if type == AppType.EXTENSION:
filter = ["addon"]
elif type == AppType.RUNTIME:
filter = ["runtime"]
else:
filter = ["desktop-application", "console-application"]

with database.get_db() as sqldb:
current_apps = set(
app.app_id
for app in sqldb.query(models.Apps.app_id)
.filter(
models.Apps.type.in_(["desktop-application", "console-application"])
)
.filter(models.Apps.type.in_(filter))
.all()
)
return list(current_apps)
Expand Down
Loading