Initial curated Unraid-AppOps-Gateway source from 3bd6f6fee310125bfbb4d4650389a817f498724d

This commit is contained in:
Public Source Publisher committed 2026-10-01 01:35:57 +02:00
commit 1dfbca08a1
528 files changed
+131054

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
from __future__ import annotations
import re
from sqlmodel import Session, select
from ..db.models import App
_APPOPS_ROLLBACK_ID = re.compile(
r'^unraid_appops_gateway(?:_1216)?_pre_\d{8}t\d{6}z$',
re.IGNORECASE,
)
def is_appops_deployment_container_name(value: str | None) -> bool:
key = str(value or '').strip().lower().replace('_', '-')
return key in {'unraid-appops-gateway', 'unraid-appops-gateway-1216'} or bool(
re.fullmatch(r'unraid-appops-gateway(?:-1216)?-pre-\d{8}t\d{6}z', key)
)
def is_historical_app_record(app: App) -> bool:
"""Keep deployment history out of active product views without deleting it."""
return bool(_APPOPS_ROLLBACK_ID.fullmatch(str(app.id or '').strip()))
def category_label(value: str | None) -> str:
words = str(value or 'Unknown').strip().replace('_', ' ').replace('-', ' ').title()
replacements = {'Ai': 'AI', 'Api': 'API', 'It': 'IT'}
return ' '.join(replacements.get(word, word) for word in words.split()) or 'Unknown'
def list_active_apps(session: Session, *, order_by: str = 'name') -> list[App]:
apps = [app for app in session.exec(select(App)).all() if not is_historical_app_record(app)]
# A port-specific canonical record supersedes the old unqualified 1211 record.
if any(app.id == 'unraid_appops_gateway_1216' for app in apps):
apps = [app for app in apps if app.id != 'unraid_appops_gateway']
key = (lambda app: app.id.lower()) if order_by == 'id' else (lambda app: app.name.lower())
return sorted(apps, key=key)