summaryrefslogtreecommitdiff
path: root/src/sql.rs
diff options
context:
space:
mode:
authoriximeow <git@iximeow.net>2022-12-22 18:29:26 +0000
committeriximeow <git@iximeow.net>2022-12-22 18:29:26 +0000
commit4a213e872395f9b0562c113bb7303815a1d26a57 (patch)
tree568464060736a76ae72337d531ac65c95192e48c /src/sql.rs
parent7734472faa9e0ecb18bab286055aceaa13c9c947 (diff)
draw almost all of the owl
Diffstat (limited to 'src/sql.rs')
-rw-r--r--src/sql.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/sql.rs b/src/sql.rs
index ee334c1..80eb18a 100644
--- a/src/sql.rs
+++ b/src/sql.rs
@@ -1,10 +1,29 @@
#![allow(dead_code)]
+use std::convert::TryFrom;
+
+#[derive(Debug, Clone)]
pub enum JobState {
Pending = 0,
Started = 1,
Complete = 2,
Error = 3,
+ Invalid = 4,
+}
+
+impl TryFrom<u8> for JobState {
+ type Error = String;
+
+ fn try_from(value: u8) -> Result<Self, String> {
+ match value {
+ 0 => Ok(JobState::Pending),
+ 1 => Ok(JobState::Started),
+ 2 => Ok(JobState::Complete),
+ 3 => Ok(JobState::Error),
+ 4 => Ok(JobState::Invalid),
+ other => Err(format!("invalid job state: {}", other)),
+ }
+ }
}
// remote_id is the remote from which we were notified. this is necessary so we know which remote
@@ -14,6 +33,7 @@ pub const CREATE_JOBS_TABLE: &'static str = "\
artifacts_path TEXT,
state INTEGER NOT NULL,
run_host TEXT,
+ build_token TEXT,
remote_id INTEGER,
commit_id INTEGER,
created_time INTEGER,
@@ -45,6 +65,9 @@ pub const CREATE_REMOTES_TABLE: &'static str = "\
pub const CREATE_REMOTES_INDEX: &'static str = "\
CREATE INDEX IF NOT EXISTS 'repo_to_remote' ON remotes(repo_id);";
+pub const CREATE_REPO_NAME_INDEX: &'static str = "\
+ CREATE UNIQUE INDEX IF NOT EXISTS 'repo_names' ON repos(repo_name);";
+
pub const PENDING_JOBS: &'static str = "\
select * from jobs where state=0;";