diff --git a/app/routers/ui.py b/app/routers/ui.py index c580765..52f1985 100644 --- a/app/routers/ui.py +++ b/app/routers/ui.py @@ -155,13 +155,14 @@ def jobs_page(request: Request, q: str = "", bracket_id: str = "", show_all: str or_(~PrintJob.status.in_(finished), PrintJob.created_at >= cutoff) ) - # Sort: printing → queued → rest, then priority, then oldest first + # Sort: printing → queued → rest, then priority flag, then internal last, then oldest first status_order = case( (PrintJob.status == JobStatus.printing, 0), (PrintJob.status == JobStatus.queued, 1), else_=2, ) - jobs = query.order_by(status_order, PrintJob.priority.desc(), PrintJob.created_at.asc()).all() + internal_last = case((PrintJob.customer == "internal", 1), else_=0) + jobs = query.order_by(status_order, PrintJob.priority.desc(), internal_last, PrintJob.created_at.asc()).all() stl_files = list_stl_files() stl_cache = get_cache_map(stl_files, db)