Refine runs table state layout
This commit is contained in:
parent
db1d9b44b7
commit
ba33491479
6 changed files with 241 additions and 31 deletions
|
|
@ -1038,11 +1038,17 @@ def _project_completed_execution(
|
|||
if execution.ended_at is not None
|
||||
else None
|
||||
)
|
||||
started_at = (
|
||||
_coerce_datetime(cast(datetime | str, execution.started_at))
|
||||
if execution.started_at is not None
|
||||
else None
|
||||
)
|
||||
return {
|
||||
"source": job.source.name,
|
||||
"slug": job.source.slug,
|
||||
"job_id": job_id,
|
||||
"execution_id": execution_id,
|
||||
"duration": _format_duration(started_at, ended_at),
|
||||
"ended_at": (
|
||||
_humanize_relative_time(reference_time, ended_at)
|
||||
if ended_at is not None
|
||||
|
|
@ -1230,6 +1236,18 @@ def _humanize_relative_time(reference_time: datetime, target_time: datetime) ->
|
|||
return f"{absolute_delta_seconds} seconds ago"
|
||||
|
||||
|
||||
def _format_duration(
|
||||
started_at: datetime | None, ended_at: datetime | None
|
||||
) -> str | None:
|
||||
if started_at is None or ended_at is None:
|
||||
return None
|
||||
|
||||
total_seconds = max(0, int((ended_at - started_at).total_seconds()))
|
||||
hours, remainder = divmod(total_seconds, 60 * 60)
|
||||
minutes, seconds = divmod(remainder, 60)
|
||||
return f"{hours:02d}:{minutes:02d}:{seconds:02d}"
|
||||
|
||||
|
||||
def _find_live_workers() -> dict[int, LiveWorker]:
|
||||
proc_dir = Path("/proc")
|
||||
if not proc_dir.exists():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue