Skip to content

Commit

Permalink
editoast: fix pr comments
Browse files Browse the repository at this point in the history
Signed-off-by: Egor Berezovskiy <[email protected]>
  • Loading branch information
Wadjetz committed Dec 19, 2024
1 parent 2bf473d commit 433f4ab
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
45 changes: 45 additions & 0 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4492,6 +4492,7 @@ components:
- $ref: '#/components/schemas/EditoastOperationErrorObjectNotFound'
- $ref: '#/components/schemas/EditoastPaginationErrorInvalidPageSize'
- $ref: '#/components/schemas/EditoastPathfindingErrorInfraNotFound'
- $ref: '#/components/schemas/EditoastPathfindingErrorRollingStockNotFound'
- $ref: '#/components/schemas/EditoastPathfindingViewErrorsEndingTrackLocationNotFound'
- $ref: '#/components/schemas/EditoastPathfindingViewErrorsInvalidNumberOfPaths'
- $ref: '#/components/schemas/EditoastPathfindingViewErrorsStartingTrackLocationNotFound'
Expand Down Expand Up @@ -4519,6 +4520,7 @@ components:
- $ref: '#/components/schemas/EditoastStdcmErrorRollingStockNotFound'
- $ref: '#/components/schemas/EditoastStdcmErrorTimetableNotFound'
- $ref: '#/components/schemas/EditoastStdcmErrorTowedRollingStockNotFound'
- $ref: '#/components/schemas/EditoastStdcmErrorTrainSimulationFail'
- $ref: '#/components/schemas/EditoastStudyErrorNotFound'
- $ref: '#/components/schemas/EditoastStudyErrorStartDateAfterEndDate'
- $ref: '#/components/schemas/EditoastTemporarySpeedLimitErrorNameAlreadyUsed'
Expand Down Expand Up @@ -5068,6 +5070,30 @@ components:
type: string
enum:
- editoast:pathfinding:InfraNotFound
EditoastPathfindingErrorRollingStockNotFound:
type: object
required:
- type
- status
- message
properties:
context:
type: object
required:
- rolling_stock_name
properties:
rolling_stock_name:
type: string
message:
type: string
status:
type: integer
enum:
- 404
type:
type: string
enum:
- editoast:pathfinding:RollingStockNotFound
EditoastPathfindingViewErrorsEndingTrackLocationNotFound:
type: object
required:
Expand Down Expand Up @@ -5690,6 +5716,25 @@ components:
type: string
enum:
- editoast:stdcm_v2:TowedRollingStockNotFound
EditoastStdcmErrorTrainSimulationFail:
type: object
required:
- type
- status
- message
properties:
context:
type: object
message:
type: string
status:
type: integer
enum:
- 400
type:
type: string
enum:
- editoast:stdcm_v2:TrainSimulationFail
EditoastStudyErrorNotFound:
type: object
required:
Expand Down
12 changes: 2 additions & 10 deletions editoast/src/views/train_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ pub enum TrainScheduleError {
#[error("{number} train schedule(s) could not be found")]
#[editoast_error(status = 404)]
BatchTrainScheduleNotFound { number: usize },
#[error("{number} rollings stock(s) could not be found")]
#[editoast_error(status = 404)]
BatchRollingStockNotFound { number: usize },
#[error("Infra '{infra_id}', could not be found")]
#[editoast_error(status = 404)]
InfraNotFound { infra_id: i64 },
Expand Down Expand Up @@ -390,13 +387,8 @@ pub async fn train_simulation_batch(
.iter()
.map::<String, _>(|t| t.rolling_stock_name.clone());

let rolling_stocks: Vec<RollingStockModel> =
RollingStockModel::retrieve_batch_or_fail(conn, rolling_stocks_ids, |missing| {
TrainScheduleError::BatchRollingStockNotFound {
number: missing.len(),
}
})
.await?;
let (rolling_stocks, _): (Vec<_>, HashSet<String>) =
RollingStockModel::retrieve_batch(conn, rolling_stocks_ids).await?;

let consists: Vec<PhysicsConsistParameters> = rolling_stocks
.into_iter()
Expand Down

0 comments on commit 433f4ab

Please sign in to comment.