Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ chumsky = { version = "0.10.1", features = ["pratt"] }
rusqlite_regex = "0.6.0"
arcstr = "1.2.0"
tokio = { version = "1.47.1", features = ["fs", "macros", "process", "rt-multi-thread"] }
tokio-stream = "0.1.17"
futures = "0.3.31"
6 changes: 3 additions & 3 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ impl Job for SparseJob {
impl AsJob for SparseJob {
fn as_job(&self, last_n: usize) -> crate::db::Job {
crate::db::Job {
name: self.name.clone(),
name: self.name.as_str().into(),
last_build: self.builds.iter().take(last_n).last().map(|b| b.number),
url: self.url.clone(),
url: self.url.as_str().into(),
}
}
}
Expand All @@ -136,7 +136,7 @@ where
let display_name = self.full_display_name_or_default();
let status = self.build_status();
Run {
url: self.url().to_string(),
url: self.url().into(),
status,
display_name: display_name.into(),
log: match status {
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub struct TagView {
pub expr: String,
}

/// Represents one tag to be loaded as [crate::parse::Tag]
/// Represents one tag to be loaded as [crate::db::TagInfo]
#[derive(Deserialize)]
pub struct ConfigTag {
/// Unique name of the tag
Expand Down
40 changes: 20 additions & 20 deletions src/db/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{db::Queryable, schema};

/// [Artifact] stored in [super::Database]
pub struct Artifact {
/// Byte contents of [Artifact]
/// Path of the [Artifact]
pub path: String,

/// Byte contents of [Artifact]
Expand Down Expand Up @@ -31,39 +31,39 @@ schema! {
}

impl Queryable for Artifact {
fn map_row(_: ()) -> impl FnMut(&rusqlite::Row) -> rusqlite::Result<super::InDatabase<Self>> {
|row| {
Ok(super::InDatabase::new(
row.get(0)?,
Artifact {
path: row.get(1)?,
contents: row.get(2)?,
run_id: row.get(3)?,
},
))
}
fn map_row(row: &rusqlite::Row) -> rusqlite::Result<super::InDatabase<Self>> {
Ok(super::InDatabase::new(
row.get(0)?,
Artifact {
path: row.get(1)?,
contents: row.get(2)?,
run_id: row.get(3)?,
},
))
}

fn as_params(&self, _: ()) -> rusqlite::Result<impl rusqlite::Params> {
fn as_params(&self) -> rusqlite::Result<impl rusqlite::Params> {
Ok((&self.path, &self.contents, self.run_id))
}
}

impl Artifact {
/// Get all [Artifact] from [super::Database] by [super::Run]
pub fn select_all_by_run(
pub async fn select_all_by_run(
db: &super::Database,
run_id: i64,
params: (),
) -> rusqlite::Result<Vec<super::InDatabase<Self>>> {
db.prepare_cached(
"
db.call(move |conn| {
conn.prepare_cached(
"
SELECT * FROM artifacts
WHERE run_id = ?
",
)?
.query_map((run_id,), Self::map_row(params))?
.collect()
)?
.query_map((run_id,), Self::map_row)?
.collect()
})
.await
}

/// Gets the [BlobFormat] of the [Artifact]
Expand Down
Loading