From 4a213e872395f9b0562c113bb7303815a1d26a57 Mon Sep 17 00:00:00 2001 From: iximeow Date: Thu, 22 Dec 2022 18:29:26 +0000 Subject: draw almost all of the owl --- src/sql.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/sql.rs') 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 for JobState { + type Error = String; + + fn try_from(value: u8) -> Result { + 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;"; -- cgit v1.1