d434517920824b8b8cd06140137.../src/main.rs
2025-08-17 17:51:48 +00:00

34 lines
963 B
Rust

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<Output, String> {
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<NaiveDate>,
pipeline_id: Vec<Uuid>,
}