Skip to content

Commit

Permalink
Fix bug in invocation reconstruction
Browse files Browse the repository at this point in the history
  • Loading branch information
DolceTriade committed Jan 3, 2024
1 parent 04f0ecb commit 1c3c5ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions blade/db/postgres/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,15 @@ impl state::DB for Postgres {
.select(models::TestRun::as_select())
.load(&mut self.conn)?;

let mut test_artifacts: std::collections::VecDeque<_> = schema::testartifacts::table
let mut test_artifacts: HashMap<String, Vec<models::TestArtifact>> = HashMap::new();
schema::testartifacts::table
.select(models::TestArtifact::as_select())
.filter(schema::testartifacts::dsl::invocation_id.eq(id))
.load(&mut self.conn)?
.grouped_by(&test_runs)
.into();
.into_iter().for_each(|a: models::TestArtifact| {
let v = test_artifacts.entry(a.test_run_id.clone()).or_insert(Vec::new());
v.push(a);
});
let test_runs = test_runs.grouped_by(&tests);
tests.into_iter().zip(test_runs).for_each(|(test, trs)| {
ret.tests.insert(
Expand All @@ -183,10 +186,9 @@ impl state::DB for Postgres {
status: state::Status::parse(&tr.status),
details: tr.details,
duration: std::time::Duration::from_secs_f64(tr.duration_s),
files: test_artifacts
.pop_front()
files: test_artifacts.get_mut(&tr.id)
.map(|v| {
v.into_iter()
v.drain(..)
.map(|ta| {
(
ta.name,
Expand Down
2 changes: 1 addition & 1 deletion blade/routes/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn get_run(
}
}

#[derive(PartialEq, Params)]
#[derive(PartialEq, Params, Debug)]
struct TestParams {
target: Option<String>,
run: Option<i32>,
Expand Down

0 comments on commit 1c3c5ce

Please sign in to comment.