Extract HTML5 operation helpers
This commit is contained in:
@@ -77,6 +77,8 @@ from api_server.html5_editor import (
|
||||
render_html5_symbols,
|
||||
)
|
||||
from api_server.html5_operations import (
|
||||
filter_html5_operation_jobs,
|
||||
latest_html5_import_job,
|
||||
render_html5_operation_detail,
|
||||
render_html5_operation_rows,
|
||||
render_html5_operation_summary,
|
||||
@@ -8333,33 +8335,16 @@ def _current_import_source(project_id: str) -> ImportSourceKind:
|
||||
|
||||
|
||||
def _html5_operation_jobs(project_id: str = "", status: str = "", kind: str = "") -> list[OperationJob]:
|
||||
normalized_project = project_id.strip().casefold()
|
||||
normalized_status = status.strip().casefold()
|
||||
normalized_kind = kind.strip().casefold()
|
||||
jobs = []
|
||||
for job in _operations.jobs.values():
|
||||
payload = job.payload or {}
|
||||
if normalized_project and str(payload.get("project_id") or "").casefold() != normalized_project:
|
||||
continue
|
||||
if normalized_status and _operation_value(getattr(job, "status", "")).casefold() != normalized_status:
|
||||
continue
|
||||
if normalized_kind and _operation_value(getattr(job, "kind", "")).casefold() != normalized_kind:
|
||||
continue
|
||||
jobs.append(job)
|
||||
return sorted(jobs, key=lambda job: job.updated_at, reverse=True)[:50]
|
||||
return filter_html5_operation_jobs(
|
||||
_operations.jobs.values(),
|
||||
project_id=project_id,
|
||||
status=status,
|
||||
kind=kind,
|
||||
)
|
||||
|
||||
|
||||
def _html5_latest_import_job(project_id: str) -> OperationJob | None:
|
||||
jobs = [
|
||||
job
|
||||
for job in _operations.jobs.values()
|
||||
if job.payload.get("project_id") == project_id and _operation_value(getattr(job, "kind", "")) == "SERVER_IMPORT"
|
||||
]
|
||||
return max(jobs, key=lambda job: job.updated_at) if jobs else None
|
||||
|
||||
|
||||
def _operation_value(value: object) -> str:
|
||||
return str(getattr(value, "value", value))
|
||||
return latest_html5_import_job(_operations.jobs.values(), project_id)
|
||||
|
||||
|
||||
def _project_summaries() -> list[ProjectSummaryResponse]:
|
||||
|
||||
Reference in New Issue
Block a user