summaryrefslogtreecommitdiff
path: root/src/dbctx.rs
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2023-06-29 01:43:12 -0700
committeriximeow <me@iximeow.net>2023-06-29 01:43:12 -0700
commit69d2943e8c97c266ebcbb3e850f0a2493f6b04b4 (patch)
tree1f85480c786a582cdbbf0eff68a296301f4e6d07 /src/dbctx.rs
parent053ff13eb080e5ad73d782e897472e40145ba4df (diff)
show job time in commit summary page
Diffstat (limited to 'src/dbctx.rs')
-rw-r--r--src/dbctx.rs28
1 files changed, 28 insertions, 0 deletions
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<Option<Job>, 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<Vec<Job>, String> {
let conn = self.conn.lock().unwrap();