diff options
author | iximeow <git@iximeow.net> | 2022-12-22 18:29:26 +0000 |
---|---|---|
committer | iximeow <git@iximeow.net> | 2022-12-22 18:29:26 +0000 |
commit | 4a213e872395f9b0562c113bb7303815a1d26a57 (patch) | |
tree | 568464060736a76ae72337d531ac65c95192e48c /src/sql.rs | |
parent | 7734472faa9e0ecb18bab286055aceaa13c9c947 (diff) |
draw almost all of the owl
Diffstat (limited to 'src/sql.rs')
-rw-r--r-- | src/sql.rs | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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;"; |