Compare commits

...

4 Commits

Author SHA1 Message Date
Martin Hohenberg
f713fbe2fb Count cancelled jobs as done in bracket progress bar
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-20 19:15:43 +02:00
Martin Hohenberg
7dec15d777 Exclude cancelled jobs from bracket progress bar count
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-19 12:26:02 +02:00
Martin Hohenberg
5270d96b92 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 <noreply@anthropic.com>
2026-06-19 12:21:19 +02:00
Martin Hohenberg
5a61a35839 Default customer to 'internal' when left blank
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-19 12:19:52 +02:00
2 changed files with 6 additions and 5 deletions

View File

@@ -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)
@@ -221,7 +222,7 @@ async def create_job(
filename = stl_select
amount = max(1, amount)
customer_str = customer.strip() or None
customer_str = customer.strip() or "internal"
job_name = Path(filename).stem if filename else (customer_str or "Unnamed")
# Resolve bracket — auto-create one when printing multiple copies
@@ -320,7 +321,7 @@ def edit_job(
job = db.query(PrintJob).filter(PrintJob.id == job_id).first()
if not job:
raise HTTPException(status_code=404, detail="Job not found")
job.customer = customer.strip() or None
job.customer = customer.strip() or "internal"
job.job_material = job_material or None
job.job_color = job_color or None
job.priority = bool(priority)

View File

@@ -23,7 +23,7 @@
<tbody>
{% for b in brackets %}
{% set total = b.jobs | length %}
{% set done = b.jobs | selectattr('status.value', 'equalto', 'done') | list | length %}
{% set done = b.jobs | selectattr('status.value', 'in', ['done', 'cancelled']) | list | length %}
{% set pct = (done / total * 100) | int if total else 0 %}
<tr>
<td><a href="/jobs?bracket_id={{ b.id }}" class="text-white text-decoration-none fw-medium">{{ b.name }}</a></td>