diff --git a/frontend/src/pages/jobs/[id].vue b/frontend/src/pages/jobs/[id].vue index a61a0c1..d12dea9 100644 --- a/frontend/src/pages/jobs/[id].vue +++ b/frontend/src/pages/jobs/[id].vue @@ -13,10 +13,12 @@ Creation time: {{ job.creation_time }}
- Finish time: {{ job.finish_time }} + Running since: {{ job.assign_time }}
Time elapsed: {{ job.elapsed_secs }}
+ Finish time: {{ job.finish_time }} +
Git commit: {{ job.git_sha }} @@ -128,6 +130,7 @@ import prettyBytes from 'pretty-bytes'; require_min_total_mem: number; require_min_total_mem_per_core: number; require_min_disk: number; + assign_time: string; git_branch: string; git_sha: string; diff --git a/server/migrations/2024-04-04-091523_add_assign_time_to_jobs/down.sql b/server/migrations/2024-04-04-091523_add_assign_time_to_jobs/down.sql new file mode 100644 index 0000000..a15f158 --- /dev/null +++ b/server/migrations/2024-04-04-091523_add_assign_time_to_jobs/down.sql @@ -0,0 +1,2 @@ +-- This file should undo anything in `up.sql` +ALTER TABLE jobs DROP COLUMN assign_time; diff --git a/server/migrations/2024-04-04-091523_add_assign_time_to_jobs/up.sql b/server/migrations/2024-04-04-091523_add_assign_time_to_jobs/up.sql new file mode 100644 index 0000000..44584b9 --- /dev/null +++ b/server/migrations/2024-04-04-091523_add_assign_time_to_jobs/up.sql @@ -0,0 +1,2 @@ +-- Your SQL goes here +ALTER TABLE jobs ADD assign_time TIMESTAMP WITH TIME ZONE; diff --git a/server/src/models.rs b/server/src/models.rs index 9921524..12e152a 100644 --- a/server/src/models.rs +++ b/server/src/models.rs @@ -59,6 +59,7 @@ pub struct Job { pub require_min_total_mem: Option, pub require_min_total_mem_per_core: Option, pub require_min_disk: Option, + pub assign_time: Option>, } #[derive(Insertable)] diff --git a/server/src/routes/job.rs b/server/src/routes/job.rs index 522c956..fc5f106 100644 --- a/server/src/routes/job.rs +++ b/server/src/routes/job.rs @@ -138,6 +138,7 @@ pub struct JobInfoResponse { require_min_total_mem: Option, require_min_total_mem_per_core: Option, require_min_disk: Option, + assign_time: Option>, // from pipeline git_branch: String, @@ -203,6 +204,7 @@ pub async fn job_info( require_min_total_mem: job.require_min_total_mem, require_min_total_mem_per_core: job.require_min_total_mem_per_core, require_min_disk: job.require_min_disk, + assign_time: job.assign_time, // from pipeline git_branch: pipeline.git_branch, diff --git a/server/src/routes/worker.rs b/server/src/routes/worker.rs index 6ba9201..b5b8a1e 100644 --- a/server/src/routes/worker.rs +++ b/server/src/routes/worker.rs @@ -228,7 +228,11 @@ pub async fn worker_poll( Some((job, pipeline)) => { // allocate to the worker diesel::update(&job) - .set((status.eq("running"), assigned_worker_id.eq(worker.id))) + .set(( + status.eq("running"), + assigned_worker_id.eq(worker.id), + assign_time.eq(chrono::Utc::now()), + )) .execute(conn)?; Ok(Some((pipeline, job))) diff --git a/server/src/schema.rs b/server/src/schema.rs index 94168aa..f68fda6 100644 --- a/server/src/schema.rs +++ b/server/src/schema.rs @@ -24,6 +24,7 @@ diesel::table! { require_min_total_mem -> Nullable, require_min_total_mem_per_core -> Nullable, require_min_disk -> Nullable, + assign_time -> Nullable, } }