From 018c655304bfc185740b3a163b369ead7d5131e8 Mon Sep 17 00:00:00 2001 From: iximeow Date: Tue, 27 Dec 2022 23:53:41 +0000 Subject: finally actually support goodfiles some more refinements to how builds are run as well: build state discusses if a build us running, where the result is either a pass or fail this is useful for deciding if a build is in progress and how artifacts (if any) should be presented --- src/sql.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/sql.rs') diff --git a/src/sql.rs b/src/sql.rs index 3476643..21572da 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -3,10 +3,16 @@ use std::convert::TryFrom; #[derive(Debug, Clone)] +pub enum JobResult { + Pass = 0, + Fail = 1, +} + +#[derive(Debug, Clone, PartialEq)] pub enum JobState { Pending = 0, Started = 1, - Complete = 2, + Finished = 2, Error = 3, Invalid = 4, } @@ -18,7 +24,7 @@ impl TryFrom for JobState { match value { 0 => Ok(JobState::Pending), 1 => Ok(JobState::Started), - 2 => Ok(JobState::Complete), + 2 => Ok(JobState::Finished), 3 => Ok(JobState::Error), 4 => Ok(JobState::Invalid), other => Err(format!("invalid job state: {}", other)), @@ -40,7 +46,9 @@ pub const CREATE_JOBS_TABLE: &'static str = "\ started_time INTEGER, complete_time INTEGER, job_timeout INTEGER, - source TEXT);"; + source TEXT, + build_result INTEGER, + final_status TEXT);"; pub const CREATE_COMMITS_TABLE: &'static str = "\ CREATE TABLE IF NOT EXISTS commits (id INTEGER PRIMARY KEY AUTOINCREMENT, sha TEXT UNIQUE);"; @@ -79,6 +87,9 @@ pub const CREATE_REPO_NAME_INDEX: &'static str = "\ pub const PENDING_JOBS: &'static str = "\ select id, artifacts_path, state, run_host, remote_id, commit_id, created_time, source from jobs where state=0;"; +pub const LAST_ARTIFACTS_FOR_JOB: &'static str = "\ + select * from artifacts where job_id=?1 and (name like \"%(stderr)%\" or name like \"%(stdout)%\") order by id desc limit 2;"; + pub const COMMIT_TO_ID: &'static str = "\ select id from commits where sha=?1;"; -- cgit v1.1