From c8f905bc6344a1889fce0e18c4c364db29ad5fc3 Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Mon, 21 Sep 2026 10:16:25 -0700 Subject: [PATCH] Add a Time column showing how long each job took --- app.py | 8 +++++--- static/index.html | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 629e7cf..55215e3 100644 --- a/app.py +++ b/app.py @@ -1483,6 +1483,7 @@ def run_job(s): "job_id": job_id, "profile": s["name"], "started": datetime.now().strftime("%Y-%m-%d %H:%M"), + "started_ts": int(datetime.now().timestamp()), "source_id": src["id"], "source_title": src["title"], "status": "running", @@ -1589,14 +1590,14 @@ def run_job(s): c.unlink(missing_ok=True) set_stage("moving files") location = finish_files(s, job_dir, job_id) - update_history(job_id, status="review" if held else "published", youtube_id=vid, location=location) + update_history(job_id, status="review" if held else "published", youtube_id=vid, location=location, finished_ts=int(datetime.now().timestamp())) set_stage("job complete", step=status["steps"]) except Cancelled: - update_history(job_id, status="cancelled") + update_history(job_id, status="cancelled", finished_ts=int(datetime.now().timestamp())) logger.warning("Job %s cancelled", job_id) raise except Exception as e: - update_history(job_id, status="failed", error=str(e)[:300]) + update_history(job_id, status="failed", error=str(e)[:300], finished_ts=int(datetime.now().timestamp())) raise finally: if compliance and not finalized and job_dir.exists(): @@ -1669,6 +1670,7 @@ def api_status(): "storage_free_gb": round(free, 1) if free is not None else None, "delete_after_publish": s["delete_after_publish"], "history": st["history"][:25], + "now": int(datetime.now().timestamp()), } diff --git a/static/index.html b/static/index.html index 94af060..557c44a 100644 --- a/static/index.html +++ b/static/index.html @@ -246,7 +246,8 @@ $("#pg-meta").textContent=pct+"% | step "+s.step+" of "+s.steps+(s.elapsed?" | " }else{panel.style.display="none"} const lb=$("#link");lb.textContent=s.channel?"Unlink YouTube Channel":"Link YouTube Channel";lb.dataset.linked=s.channel?"1":""; setButton(s.running); -$("#jobs").innerHTML="StartedProfileSourceTitleStatusVideo"+s.history.map(h=>`${esc(h.started)}${esc(h.profile)}${esc(h.source_title)}${esc(h.title)}${h.status==="review"?"private, needs review":esc(h.status)}${h.notes?`
Reviewer notes: ${esc(h.notes)}
`:""}${h.error?`
${esc(h.error)}
`:""}${h.location?`
${esc(h.location)}
`:""}${h.youtube_id?`studio open`:""}`).join("") +const dur=h=>{if(!h.started_ts)return"";const end=h.finished_ts||(h.status==="running"?s.now:0);if(!end)return"";const d=Math.max(0,end-h.started_ts);const m=Math.floor(d/60),sec=d%60;return(m?m+"m ":"")+sec+"s"}; +$("#jobs").innerHTML="StartedTimeProfileSourceTitleStatusVideo"+s.history.map(h=>`${esc(h.started)}${esc(dur(h))}${esc(h.profile)}${esc(h.source_title)}${esc(h.title)}${h.status==="review"?"private, needs review":esc(h.status)}${h.notes?`
Reviewer notes: ${esc(h.notes)}
`:""}${h.error?`
${esc(h.error)}
`:""}${h.location?`
${esc(h.location)}
`:""}${h.youtube_id?`studio open`:""}`).join("") }catch(e){}} let since=0; async function pollLogs(){