Rename Dependency.dependency to Dependency.product
This commit is contained in:
parent
2d7250e943
commit
d422e83275
@ -270,18 +270,18 @@ impl UpdateBalancesAt {
|
|||||||
// Check for BalancesAt -> Transactions
|
// Check for BalancesAt -> Transactions
|
||||||
let dependencies_for_step = dependencies.dependencies_for_step(&step.id());
|
let dependencies_for_step = dependencies.dependencies_for_step(&step.id());
|
||||||
if dependencies_for_step.len() == 1
|
if dependencies_for_step.len() == 1
|
||||||
&& dependencies_for_step[0].dependency.kind == ReportingProductKind::BalancesAt
|
&& dependencies_for_step[0].product.kind == ReportingProductKind::BalancesAt
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if BalancesBetween -> Transactions and BalancesAt is available
|
// Check if BalancesBetween -> Transactions and BalancesAt is available
|
||||||
if dependencies_for_step.len() == 1
|
if dependencies_for_step.len() == 1
|
||||||
&& dependencies_for_step[0].dependency.kind
|
&& dependencies_for_step[0].product.kind
|
||||||
== ReportingProductKind::BalancesBetween
|
== ReportingProductKind::BalancesBetween
|
||||||
{
|
{
|
||||||
let date_end = dependencies_for_step[0]
|
let date_end = dependencies_for_step[0]
|
||||||
.dependency
|
.product
|
||||||
.args
|
.args
|
||||||
.downcast_ref::<DateStartDateEndArgs>()
|
.downcast_ref::<DateStartDateEndArgs>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -289,7 +289,7 @@ impl UpdateBalancesAt {
|
|||||||
|
|
||||||
match has_step_or_can_build(
|
match has_step_or_can_build(
|
||||||
&ReportingProductId {
|
&ReportingProductId {
|
||||||
name: dependencies_for_step[0].dependency.name,
|
name: dependencies_for_step[0].product.name,
|
||||||
kind: ReportingProductKind::BalancesAt,
|
kind: ReportingProductKind::BalancesAt,
|
||||||
args: Box::new(DateArgs { date: date_end }),
|
args: Box::new(DateArgs { date: date_end }),
|
||||||
},
|
},
|
||||||
@ -398,7 +398,7 @@ impl UpdateBalancesBetween {
|
|||||||
// Check for BalancesBetween -> Transactions
|
// Check for BalancesBetween -> Transactions
|
||||||
let dependencies_for_step = dependencies.dependencies_for_step(&step.id());
|
let dependencies_for_step = dependencies.dependencies_for_step(&step.id());
|
||||||
if dependencies_for_step.len() == 1
|
if dependencies_for_step.len() == 1
|
||||||
&& dependencies_for_step[0].dependency.kind
|
&& dependencies_for_step[0].product.kind
|
||||||
== ReportingProductKind::BalancesBetween
|
== ReportingProductKind::BalancesBetween
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -35,9 +35,9 @@ impl ReportingGraphDependencies {
|
|||||||
if !self
|
if !self
|
||||||
.vec
|
.vec
|
||||||
.iter()
|
.iter()
|
||||||
.any(|d| d.step == step && d.dependency == dependency)
|
.any(|d| d.step == step && d.product == dependency)
|
||||||
{
|
{
|
||||||
self.vec.push(Dependency { step, dependency });
|
self.vec.push(Dependency { step, product: dependency });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,10 +65,11 @@ impl ReportingGraphDependencies {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Represents that a [ReportingStep] depends on a [ReportingProduct]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Dependency {
|
pub struct Dependency {
|
||||||
pub step: ReportingStepId,
|
pub step: ReportingStepId,
|
||||||
pub dependency: ReportingProductId,
|
pub product: ReportingProductId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -147,12 +148,12 @@ fn would_be_ready_to_execute(
|
|||||||
|
|
||||||
// Check if the dependency has been produced by a previous step
|
// Check if the dependency has been produced by a previous step
|
||||||
for previous_step in previous_steps {
|
for previous_step in previous_steps {
|
||||||
if steps[*previous_step].id().name == dependency.dependency.name
|
if steps[*previous_step].id().name == dependency.product.name
|
||||||
&& steps[*previous_step].id().args == dependency.dependency.args
|
&& steps[*previous_step].id().args == dependency.product.args
|
||||||
&& steps[*previous_step]
|
&& steps[*previous_step]
|
||||||
.id()
|
.id()
|
||||||
.product_kinds
|
.product_kinds
|
||||||
.contains(&dependency.dependency.kind)
|
.contains(&dependency.product.kind)
|
||||||
{
|
{
|
||||||
continue 'check_each_dependency;
|
continue 'check_each_dependency;
|
||||||
}
|
}
|
||||||
@ -197,33 +198,33 @@ pub fn solve_for(
|
|||||||
todo!();
|
todo!();
|
||||||
}
|
}
|
||||||
if !steps.iter().any(|s| {
|
if !steps.iter().any(|s| {
|
||||||
s.id().name == dependency.dependency.name
|
s.id().name == dependency.product.name
|
||||||
&& s.id().args == dependency.dependency.args
|
&& s.id().args == dependency.product.args
|
||||||
&& s.id().product_kinds.contains(&dependency.dependency.kind)
|
&& s.id().product_kinds.contains(&dependency.product.kind)
|
||||||
}) {
|
}) {
|
||||||
// Try lookup function
|
// Try lookup function
|
||||||
if let Some(lookup_key) = context.step_lookup_fn.keys().find(|(name, kinds)| {
|
if let Some(lookup_key) = context.step_lookup_fn.keys().find(|(name, kinds)| {
|
||||||
*name == dependency.dependency.name
|
*name == dependency.product.name
|
||||||
&& kinds.contains(&dependency.dependency.kind)
|
&& kinds.contains(&dependency.product.kind)
|
||||||
}) {
|
}) {
|
||||||
let (takes_args_fn, from_args_fn) =
|
let (takes_args_fn, from_args_fn) =
|
||||||
context.step_lookup_fn.get(lookup_key).unwrap();
|
context.step_lookup_fn.get(lookup_key).unwrap();
|
||||||
if takes_args_fn(&dependency.dependency.args) {
|
if takes_args_fn(&dependency.product.args) {
|
||||||
let new_step = from_args_fn(dependency.dependency.args.clone());
|
let new_step = from_args_fn(dependency.product.args.clone());
|
||||||
|
|
||||||
// Check new step meets the dependency
|
// Check new step meets the dependency
|
||||||
if new_step.id().name != dependency.dependency.name {
|
if new_step.id().name != dependency.product.name {
|
||||||
panic!("Unexpected step returned from lookup function (expected name {}, got {})", dependency.dependency.name, new_step.id().name);
|
panic!("Unexpected step returned from lookup function (expected name {}, got {})", dependency.product.name, new_step.id().name);
|
||||||
}
|
}
|
||||||
if new_step.id().args != dependency.dependency.args {
|
if new_step.id().args != dependency.product.args {
|
||||||
panic!("Unexpected step returned from lookup function {} (expected args {:?}, got {:?})", dependency.dependency.name, dependency.dependency.args, new_step.id().args);
|
panic!("Unexpected step returned from lookup function {} (expected args {:?}, got {:?})", dependency.product.name, dependency.product.args, new_step.id().args);
|
||||||
}
|
}
|
||||||
if !new_step
|
if !new_step
|
||||||
.id()
|
.id()
|
||||||
.product_kinds
|
.product_kinds
|
||||||
.contains(&dependency.dependency.kind)
|
.contains(&dependency.product.kind)
|
||||||
{
|
{
|
||||||
panic!("Unexpected step returned from lookup function {} (expected kind {:?}, got {:?})", dependency.dependency.name, dependency.dependency.kind, new_step.id().product_kinds);
|
panic!("Unexpected step returned from lookup function {} (expected kind {:?}, got {:?})", dependency.product.name, dependency.product.kind, new_step.id().product_kinds);
|
||||||
}
|
}
|
||||||
|
|
||||||
new_steps.push(new_step);
|
new_steps.push(new_step);
|
||||||
@ -234,17 +235,17 @@ pub fn solve_for(
|
|||||||
// No explicit step for product - try builders
|
// No explicit step for product - try builders
|
||||||
for builder in context.step_dynamic_builders.iter() {
|
for builder in context.step_dynamic_builders.iter() {
|
||||||
if (builder.can_build)(
|
if (builder.can_build)(
|
||||||
dependency.dependency.name,
|
dependency.product.name,
|
||||||
dependency.dependency.kind,
|
dependency.product.kind,
|
||||||
&dependency.dependency.args,
|
&dependency.product.args,
|
||||||
&steps,
|
&steps,
|
||||||
&dependencies,
|
&dependencies,
|
||||||
&context,
|
&context,
|
||||||
) {
|
) {
|
||||||
new_steps.push((builder.build)(
|
new_steps.push((builder.build)(
|
||||||
dependency.dependency.name,
|
dependency.product.name,
|
||||||
dependency.dependency.kind,
|
dependency.product.kind,
|
||||||
dependency.dependency.args.clone(),
|
dependency.product.args.clone(),
|
||||||
&steps,
|
&steps,
|
||||||
&dependencies,
|
&dependencies,
|
||||||
&context,
|
&context,
|
||||||
@ -283,19 +284,19 @@ pub fn solve_for(
|
|||||||
return Err(ReportingCalculationError::UnknownStep {
|
return Err(ReportingCalculationError::UnknownStep {
|
||||||
message: format!(
|
message: format!(
|
||||||
"No implementation for step {} which {} is a dependency of",
|
"No implementation for step {} which {} is a dependency of",
|
||||||
dependency.step, dependency.dependency
|
dependency.step, dependency.product
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if !steps.iter().any(|s| {
|
if !steps.iter().any(|s| {
|
||||||
s.id().name == dependency.dependency.name
|
s.id().name == dependency.product.name
|
||||||
&& s.id().args == dependency.dependency.args
|
&& s.id().args == dependency.product.args
|
||||||
&& s.id().product_kinds.contains(&dependency.dependency.kind)
|
&& s.id().product_kinds.contains(&dependency.product.kind)
|
||||||
}) {
|
}) {
|
||||||
return Err(ReportingCalculationError::NoStepForProduct {
|
return Err(ReportingCalculationError::NoStepForProduct {
|
||||||
message: format!(
|
message: format!(
|
||||||
"No step builds product {} wanted by {}",
|
"No step builds product {} wanted by {}",
|
||||||
dependency.dependency, dependency.step
|
dependency.product, dependency.step
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user