Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error reporting to timetable import #6161

Merged
merged 4 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 64 additions & 2 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3308,6 +3308,55 @@ components:
- id
- name
type: object
TimetableImportError:
oneOf:
- properties:
RollingStockNotFound:
properties:
name:
type: string
required:
- name
type: object
required:
- RollingStockNotFound
type: object
- properties:
OperationalPointNotFound:
properties:
missing_uics:
items:
format: int64
type: integer
type: array
required:
- missing_uics
type: object
required:
- OperationalPointNotFound
type: object
- properties:
PathfindingError:
properties:
cause:
$ref: '#/components/schemas/InternalError'
required:
- cause
type: object
required:
- PathfindingError
type: object
- properties:
SimulationError:
properties:
cause:
$ref: '#/components/schemas/InternalError'
required:
- cause
type: object
required:
- SimulationError
type: object
TimetableImportItem:
properties:
path:
Expand Down Expand Up @@ -3382,6 +3431,15 @@ components:
required:
- location
type: object
TimetableImportReport:
properties:
errors:
additionalProperties:
$ref: '#/components/schemas/TimetableImportError'
type: object
required:
- errors
type: object
TimetableImportTrain:
properties:
departure_time:
Expand Down Expand Up @@ -6001,8 +6059,12 @@ paths:
description: ''
required: true
responses:
'204':
description: Timetable was successfully imported
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/TimetableImportReport'
description: Import report
summary: Import a timetable
tags:
- timetable
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/core/pathfinding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct PathfindingRequest {
rolling_stocks: Vec<RollingStock>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Waypoint {
track_section: String,
offset: f64,
Expand Down
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>,
Khoyo marked this conversation as resolved.
Show resolved Hide resolved
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
Loading
Loading