Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68a3892477 |
3543
Cargo.lock
generated
Normal file
3543
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
Normal file
12
Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[package]
|
||||||
|
edition = "2024"
|
||||||
|
name = "web"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
chrono = { version = "0.4" }
|
||||||
|
fathom-function = { git = "ssh://git@github.com/fathom-io/pipeline-calculations.git", branch = "johnabell/ili-comparison" }
|
||||||
|
pipeline-application = { git = "ssh://git@github.com/fathom-io/pipeline-calculations.git", branch = "johnabell/ili-comparison" }
|
||||||
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
|
tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread"] }
|
||||||
|
uuid = { version = "1" }
|
||||||
81
src/main.rs
Normal file
81
src/main.rs
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
use chrono::NaiveDate;
|
||||||
|
use pipeline_application::application::{
|
||||||
|
Application, Env, InlineInspection, InspectionType, ReportType, ToolTolerances,
|
||||||
|
};
|
||||||
|
use serde::{Deserialize, Deserializer, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
#[fathom_function::function]
|
||||||
|
async fn pipeline_route(input: Input) -> Result<Output, String> {
|
||||||
|
let reports_details = input.report_details;
|
||||||
|
let app = Application::new(Env::Dev, input.org_id, input.project_id).unwrap();
|
||||||
|
|
||||||
|
for (pipeline_id, file_details) in input.pipeline_id.into_iter().zip(input.file_details) {
|
||||||
|
app.process_ili_report(
|
||||||
|
pipeline_id,
|
||||||
|
file_details.file_id,
|
||||||
|
ToolTolerances::default(),
|
||||||
|
&reports_details,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
Ok(Output {
|
||||||
|
status: "Success".to_owned(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
struct Output {
|
||||||
|
status: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
struct Input {
|
||||||
|
org_id: Uuid,
|
||||||
|
project_id: String,
|
||||||
|
pipeline_id: Vec<Uuid>,
|
||||||
|
file_details: Vec<FileDetails>,
|
||||||
|
// TODO: parse the output of the tool tolerances.
|
||||||
|
#[serde(flatten)]
|
||||||
|
report_details: InspectionReportDetails,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
struct InspectionReportDetails {
|
||||||
|
#[serde(deserialize_with = "deserialize_date")]
|
||||||
|
date: NaiveDate,
|
||||||
|
vendor_name: String,
|
||||||
|
report_type: ReportType,
|
||||||
|
/// The inspection type and technology used.
|
||||||
|
inspection_type: InspectionType,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&InspectionReportDetails> for InlineInspection {
|
||||||
|
fn from(value: &InspectionReportDetails) -> Self {
|
||||||
|
Self {
|
||||||
|
date: value.date,
|
||||||
|
vendor_name: value.vendor_name.to_owned(),
|
||||||
|
report_type: value.report_type,
|
||||||
|
inspection_type: value.inspection_type,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct FileDetails {
|
||||||
|
pub file_id: Uuid,
|
||||||
|
pub revision_id: Uuid,
|
||||||
|
}
|
||||||
|
|
||||||
|
const FORMAT: &'static str = "%a %b %d %Y";
|
||||||
|
|
||||||
|
pub fn deserialize_date<'de, D>(deserializer: D) -> Result<NaiveDate, D::Error>
|
||||||
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
|
let s = String::deserialize(deserializer)?;
|
||||||
|
let dt = NaiveDate::parse_from_str(&s, FORMAT).map_err(serde::de::Error::custom)?;
|
||||||
|
Ok(dt)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user