From 69d2943e8c97c266ebcbb3e850f0a2493f6b04b4 Mon Sep 17 00:00:00 2001 From: iximeow Date: Thu, 29 Jun 2023 01:43:12 -0700 Subject: show job time in commit summary page --- src/dbctx.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/dbctx.rs') diff --git a/src/dbctx.rs b/src/dbctx.rs index 3cc82be..a5de23d 100644 --- a/src/dbctx.rs +++ b/src/dbctx.rs @@ -384,6 +384,34 @@ impl DbCtx { .map(|mut jobs| jobs.pop()) } + pub fn job_by_commit_id(&self, commit_id: u64) -> Result, String> { + let conn = self.conn.lock().unwrap(); + + conn + .query_row(sql::JOB_BY_COMMIT_ID, [commit_id], |row| { + let (id, artifacts_path, state, run_host, remote_id, commit_id, created_time, start_time, complete_time, build_token, job_timeout, source, build_result, final_text) = row.try_into().unwrap(); + let state: u8 = state; + Ok(Job { + id, + artifacts_path, + state: state.try_into().unwrap(), + run_host, + remote_id, + commit_id, + created_time, + start_time, + complete_time, + build_token, + job_timeout, + source, + build_result, + final_text, + }) + }) + .optional() + .map_err(|e| e.to_string()) + } + pub fn recent_jobs_from_remote(&self, id: u64, limit: u64) -> Result, String> { let conn = self.conn.lock().unwrap(); -- cgit v1.1