chore: Add restarted flow test in worker.rs (#2524)
* chore: Add restarted flow test in worker.rs * small refactor to rust code * Fix unused imports
This commit is contained in:
committed by
GitHub
parent
a87a441c14
commit
729bf59558
@@ -6,7 +6,11 @@
|
||||
* LICENSE-AGPL for a copy of the license.
|
||||
*/
|
||||
|
||||
use std::{collections::HashMap, iter, sync::Arc, vec};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
sync::Arc,
|
||||
vec,
|
||||
};
|
||||
|
||||
use anyhow::Context;
|
||||
use async_recursion::async_recursion;
|
||||
@@ -19,7 +23,6 @@ use axum::{
|
||||
};
|
||||
use bigdecimal::ToPrimitive;
|
||||
use chrono::{DateTime, Duration, Utc};
|
||||
use itertools::Itertools;
|
||||
use prometheus::IntCounter;
|
||||
use reqwest::{
|
||||
header::{HeaderMap, CONTENT_TYPE},
|
||||
@@ -1681,19 +1684,18 @@ async fn compute_leaf_jobs_for_completed_flow(
|
||||
// we add the module as an element of ListJob for this step ID and recursiively extract leaf job of the sub-flow
|
||||
match module {
|
||||
FlowStatusModule::Success { flow_jobs: Some(jobs), .. } => {
|
||||
for job in jobs {
|
||||
if *job == child_job_id {
|
||||
let new_list_job = match recursive_result.get(&module.id()) {
|
||||
Some(JobResult::ListJob(jobs_list)) => jobs_list
|
||||
.into_iter()
|
||||
.chain(iter::once(&child_job_id))
|
||||
.cloned()
|
||||
.collect_vec(),
|
||||
_ => iter::once(&child_job_id).cloned().collect_vec(),
|
||||
};
|
||||
recursive_result
|
||||
.insert(module.id(), JobResult::ListJob(new_list_job));
|
||||
}
|
||||
let jobs_set: HashSet<Uuid> = HashSet::from_iter(jobs.iter().cloned());
|
||||
if jobs_set.contains(&child_job_id) {
|
||||
let new_list_job = match recursive_result.get(&module.id()) {
|
||||
Some(JobResult::ListJob(jobs_list)) => {
|
||||
let mut jobs_list_c = jobs_list.clone();
|
||||
jobs_list_c.push(child_job_id);
|
||||
jobs_list_c
|
||||
}
|
||||
_ => vec![child_job_id],
|
||||
};
|
||||
recursive_result
|
||||
.insert(module.id(), JobResult::ListJob(new_list_job));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
||||
Reference in New Issue
Block a user