Skip to content

Commit

Permalink
editoast: timetable: refactor the import and report errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Khoyo committed Jan 17, 2024
1 parent 38806d6 commit d8474a6
Show file tree
Hide file tree
Showing 5 changed files with 304 additions and 177 deletions.
2 changes: 1 addition & 1 deletion editoast/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn default_status_code() -> StatusCode {
StatusCode::INTERNAL_SERVER_ERROR
}

#[derive(Debug, Serialize, Deserialize, ToSchema, PartialEq)]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, PartialEq)]
pub struct InternalError {
#[serde(with = "StatusCodeRemoteDef", default = "default_status_code")]
#[schema(value_type = u16, minimum = 100, maximum = 599)]
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/models/infra_objects/operational_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl OperationalPointModel {
pub async fn retrieve_from_uic(
conn: &mut PgConnection,
infra_id: i64,
uic: Vec<i64>,
uic: &[i64],
) -> Result<Vec<Self>> {
let query = "SELECT * FROM infra_object_operational_point
WHERE infra_id = $1 AND (data->'extensions'->'identifier'->'uic')::integer = ANY($2)".to_string();
Expand Down
6 changes: 3 additions & 3 deletions editoast/src/views/pathfinding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ async fn call_core_pf_and_save_result(
let steps_duration = payload.steps.iter().map(|step| step.duration).collect();
run_pathfinding(
&path_request,
core,
core.as_ref(),
conn,
infra_id,
update_id,
Expand All @@ -473,14 +473,14 @@ async fn call_core_pf_and_save_result(
/// If `update_id` is provided then update the corresponding path instead of creating a new one
pub async fn run_pathfinding(
path_request: &CorePathfindingRequest,
core: Data<CoreClient>,
core: &CoreClient,
conn: &mut PgConnection,
infra_id: i64,
update_id: Option<i64>,
steps_duration: Vec<f64>,
) -> Result<Pathfinding> {
assert_eq!(steps_duration.len(), path_request.nb_waypoints());
let response = path_request.fetch(core.as_ref()).await?;
let response = path_request.fetch(core).await?;
let response_track_map = response.fetch_track_map(infra_id, conn).await?;
let response_op_map = response.fetch_op_map(infra_id, conn).await?;
let pathfinding = Pathfinding::from_core_response(
Expand Down
1 change: 0 additions & 1 deletion editoast/src/views/timetable.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::cmp::Ordering;
use std::collections::HashMap;

use crate::core::conflicts::{ConflicDetectionRequest, TrainRequirement};
Expand Down
Loading

0 comments on commit d8474a6

Please sign in to comment.