Add a Time column showing how long each job took
This commit is contained in:
1 parent
47433dbfa8
commit
c8f905bc63
2 files changed
+7
-4
No files matched your search
@@ -1483,6 +1483,7 @@ def run_job(s):
|
|||||||
"job_id": job_id,
|
"job_id": job_id,
|
||||||
"profile": s["name"],
|
"profile": s["name"],
|
||||||
"started": datetime.now().strftime("%Y-%m-%d %H:%M"),
|
"started": datetime.now().strftime("%Y-%m-%d %H:%M"),
|
||||||
|
"started_ts": int(datetime.now().timestamp()),
|
||||||
"source_id": src["id"],
|
"source_id": src["id"],
|
||||||
"source_title": src["title"],
|
"source_title": src["title"],
|
||||||
"status": "running",
|
"status": "running",
|
||||||
@@ -1589,14 +1590,14 @@ def run_job(s):
|
|||||||
c.unlink(missing_ok=True)
|
c.unlink(missing_ok=True)
|
||||||
set_stage("moving files")
|
set_stage("moving files")
|
||||||
location = finish_files(s, job_dir, job_id)
|
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"])
|
set_stage("job complete", step=status["steps"])
|
||||||
except Cancelled:
|
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)
|
logger.warning("Job %s cancelled", job_id)
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
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
|
raise
|
||||||
finally:
|
finally:
|
||||||
if compliance and not finalized and job_dir.exists():
|
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,
|
"storage_free_gb": round(free, 1) if free is not None else None,
|
||||||
"delete_after_publish": s["delete_after_publish"],
|
"delete_after_publish": s["delete_after_publish"],
|
||||||
"history": st["history"][:25],
|
"history": st["history"][:25],
|
||||||
|
"now": int(datetime.now().timestamp()),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -246,7 +246,8 @@ $("#pg-meta").textContent=pct+"% | step "+s.step+" of "+s.steps+(s.elapsed?" | "
|
|||||||
}else{panel.style.display="none"}
|
}else{panel.style.display="none"}
|
||||||
const lb=$("#link");lb.textContent=s.channel?"Unlink YouTube Channel":"Link YouTube Channel";lb.dataset.linked=s.channel?"1":"";
|
const lb=$("#link");lb.textContent=s.channel?"Unlink YouTube Channel":"Link YouTube Channel";lb.dataset.linked=s.channel?"1":"";
|
||||||
setButton(s.running);
|
setButton(s.running);
|
||||||
$("#jobs").innerHTML="<tr><th>Started</th><th>Profile</th><th>Source</th><th>Title</th><th>Status</th><th>Video</th></tr>"+s.history.map(h=>`<tr><td>${esc(h.started)}</td><td>${esc(h.profile)}</td><td><a target="_blank" href="https://youtube.com/watch?v=${esc(h.source_id)}">${esc(h.source_title)}</a></td><td>${esc(h.title)}</td><td><span class="pill ${esc(h.status)}">${h.status==="review"?"private, needs review":esc(h.status)}</span>${h.notes?`<div class="hint notes">Reviewer notes: ${esc(h.notes)}</div>`:""}${h.error?`<div class="hint">${esc(h.error)}</div>`:""}${h.location?`<div class="hint">${esc(h.location)}</div>`:""}</td><td>${h.youtube_id?`<a target="_blank" href="https://studio.youtube.com/video/${esc(h.youtube_id)}/edit">studio</a> <a target="_blank" href="https://youtube.com/shorts/${esc(h.youtube_id)}">open</a>`:""}</td></tr>`).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="<tr><th>Started</th><th>Time</th><th>Profile</th><th>Source</th><th>Title</th><th>Status</th><th>Video</th></tr>"+s.history.map(h=>`<tr><td>${esc(h.started)}</td><td style="white-space:nowrap">${esc(dur(h))}</td><td>${esc(h.profile)}</td><td><a target="_blank" href="https://youtube.com/watch?v=${esc(h.source_id)}">${esc(h.source_title)}</a></td><td>${esc(h.title)}</td><td><span class="pill ${esc(h.status)}">${h.status==="review"?"private, needs review":esc(h.status)}</span>${h.notes?`<div class="hint notes">Reviewer notes: ${esc(h.notes)}</div>`:""}${h.error?`<div class="hint">${esc(h.error)}</div>`:""}${h.location?`<div class="hint">${esc(h.location)}</div>`:""}</td><td>${h.youtube_id?`<a target="_blank" href="https://studio.youtube.com/video/${esc(h.youtube_id)}/edit">studio</a> <a target="_blank" href="https://youtube.com/shorts/${esc(h.youtube_id)}">open</a>`:""}</td></tr>`).join("")
|
||||||
}catch(e){}}
|
}catch(e){}}
|
||||||
let since=0;
|
let since=0;
|
||||||
async function pollLogs(){
|
async function pollLogs(){
|
||||||
|
|||||||
Reference in new issue
Block a user