From 5270d96b92d4d42b2dab61822de48202cb1009a6 Mon Sep 17 00:00:00 2001 From: Martin Hohenberg Date: Fri, 19 Jun 2026 12:21:19 +0200 Subject: [PATCH] Sort jobs: internal always last within each priority stratum Order: priority customer > priority internal > normal customer > normal internal Co-Authored-By: Claude Sonnet 4.6 --- app/routers/ui.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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)