feat: Fixes errors with estimating pressures that include a filter pressure drop.
This commit is contained in:
@@ -215,49 +215,6 @@ public struct FlaggedMeasurementsList: Sendable {
|
||||
flaggedMeasurement: flaggedMeasurement
|
||||
)
|
||||
}
|
||||
|
||||
#warning("This is making it hard to test, perhaps don't return an effect here.")
|
||||
private func handleEstimationForm(form: EstimationForm.State, state: State) -> Effect<Action> {
|
||||
guard let equipmentMeasurement = state.sharedSettings.equipmentMeasurement,
|
||||
let budgets = state.sharedSettings.budgets
|
||||
else {
|
||||
return .fail(
|
||||
"""
|
||||
Received estimation form done button tapped action, original
|
||||
equipment measurement or budgets are not set on the shared state.
|
||||
|
||||
This is considered an application logic error.
|
||||
""",
|
||||
logger: logger
|
||||
)
|
||||
}
|
||||
|
||||
guard let estimationState = ensureHasChanges(
|
||||
formState: form,
|
||||
flaggedEstimations: state.sharedSettings.flaggedEstimations
|
||||
) else {
|
||||
logger.debug("No changes found, not generating a new flagged estimation measurement.")
|
||||
return .none
|
||||
}
|
||||
|
||||
return .receive(action: \.receive) { [sharedSettings = state.sharedSettings] in
|
||||
|
||||
let flaggedMeasurement = try await flaggedMeasurement(
|
||||
airflow: estimationState.cfm.airflow,
|
||||
budgets: budgets,
|
||||
equipmentMeasurement: equipmentMeasurement,
|
||||
filterPressureDrop: parseFilterPressureDrop(formState: form, sharedSettings: sharedSettings),
|
||||
ratedStaticPresures: sharedSettings.ratedStaticPressures,
|
||||
tons: form.coolingCapacity
|
||||
)
|
||||
|
||||
return .estimatedFlaggedMeasurement(.init(
|
||||
id: form.id ?? uuid(),
|
||||
estimationState: estimationState,
|
||||
flaggedMeasurement: flaggedMeasurement
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
func ensureHasChanges(
|
||||
formState: EstimationForm.State,
|
||||
|
||||
Reference in New Issue
Block a user