54 lines
1.9 KiB
Rust
54 lines
1.9 KiB
Rust
use fathom_function::Context;
|
|
use pipeline_application::application::{Application, SegmentationConfiguration};
|
|
use pipeline_configuration::facilities::FacilityType;
|
|
|
|
#[fathom_function::function(default(
|
|
org_id = "2cbfe270-d195-48ad-aed1-24145924635c",
|
|
project_id = "6807aed617c4295ab4a6aa78"
|
|
))]
|
|
async fn segment(context: Context, args: Args) -> Result<String, String> {
|
|
Application::new(context.env, context.org_id, context.project_id)
|
|
.unwrap()
|
|
.segment_all(args)
|
|
.await
|
|
.map_err(|err| err.to_string())?;
|
|
|
|
Ok("Success".to_string())
|
|
}
|
|
|
|
#[derive(Debug, serde::Deserialize)]
|
|
struct Args {
|
|
facilities: Vec<FacilityType>,
|
|
local_data: Vec<String>,
|
|
}
|
|
|
|
impl From<Args> for SegmentationConfiguration {
|
|
fn from(value: Args) -> Self {
|
|
let mut config = Self::default_false();
|
|
for fac in value.facilities {
|
|
config = match fac {
|
|
FacilityType::InsulationJoint => config.by_insulation_joints(true),
|
|
FacilityType::Repair => config.by_repairs(true),
|
|
FacilityType::Valve => config.by_valves(true),
|
|
_ => config,
|
|
};
|
|
}
|
|
// TODO: add crossing configuration
|
|
for loc in value.local_data {
|
|
config = match loc.as_str() {
|
|
"material_grade" => config.by_material_grade(true),
|
|
"coating_type" => config.by_coating_type(true),
|
|
"design_factor" => config.by_design_factor(true),
|
|
"high_consequence_area" => config.by_high_consequence_area(true),
|
|
"unusual_sensitive_area" => config.by_unusual_sensitive_area(true),
|
|
"joint_type" => config.by_joint_type(true),
|
|
"soil_type" => config.by_soil_type(true),
|
|
"soil_ph" => config.by_soil_ph(true),
|
|
_ => config,
|
|
}
|
|
}
|
|
|
|
config
|
|
}
|
|
}
|