summaryrefslogtreecommitdiff
path: root/src/dbctx.rs
diff options
context:
space:
mode:
authoriximeow <git@iximeow.net>2022-12-27 23:53:41 +0000
committeriximeow <git@iximeow.net>2022-12-27 23:53:41 +0000
commit018c655304bfc185740b3a163b369ead7d5131e8 (patch)
treef04024ad72a38e75460b8453aa46e08b08a32a97 /src/dbctx.rs
parent3411ef67fb829c419f853293664d97c6a6d4b96b (diff)
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
Diffstat (limited to 'src/dbctx.rs')
-rw-r--r--src/dbctx.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/dbctx.rs b/src/dbctx.rs
index 1bb8bc8..cb74010 100644
--- a/src/dbctx.rs
+++ b/src/dbctx.rs
@@ -37,6 +37,14 @@ pub enum TokenValidity {
Valid,
}
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct ArtifactRecord {
+ pub id: u64,
+ pub job_id: u64,
+ pub name: String,
+ pub desc: String
+}
+
pub struct ArtifactDescriptor {
job_id: u64,
artifact_id: u64,
@@ -257,6 +265,21 @@ impl DbCtx {
Ok(conn.last_insert_rowid() as u64)
}
+ pub fn artifacts_for_job(&self, job: u64) -> Result<Vec<ArtifactRecord>, String> {
+ let conn = self.conn.lock().unwrap();
+
+ let mut artifacts_query = conn.prepare(sql::LAST_ARTIFACTS_FOR_JOB).unwrap();
+ let mut result = artifacts_query.query([job]).unwrap();
+ let mut artifacts = Vec::new();
+
+ while let Some(row) = result.next().unwrap() {
+ let (id, job_id, name, desc): (u64, u64, String, String) = row.try_into().unwrap();
+ artifacts.push(ArtifactRecord { id, job_id, name, desc });
+ }
+
+ Ok(artifacts)
+ }
+
pub fn get_pending_jobs(&self) -> Result<Vec<PendingJob>, String> {
let conn = self.conn.lock().unwrap();