use fathom_function::{chrono::NaiveDate, tracing}; use pipeline_application::application::Application; use serde::{Deserialize, Serialize}; use uuid::Uuid; #[fathom_function::function] async fn time_weighted_calculation(input: Input) -> Result { let app = Application::new_from_compile_env(input.org_id, &input.project_id).unwrap(); for pipeline_id in input.pipeline_id { app.time_weighted_calculation(pipeline_id, input.target_date) .await .map_err(|err| { tracing::error!(%pipeline_id, ?err, "Error running time weighted corrosion calculation"); format!("{err:?}") })?; } Ok(Output { status: "Success".to_owned(), }) } #[derive(Debug, Serialize)] struct Output { status: String, } #[derive(Debug, Deserialize)] struct Input { org_id: Uuid, project_id: String, target_date: Option, pipeline_id: Vec, }