Skip to content

Commit fd5f3cf

Browse files
committed
editoast: add OperationalPointIdLocation as location for POST timetable
1 parent 472bff2 commit fd5f3cf

File tree

4 files changed

+201
-38
lines changed

4 files changed

+201
-38
lines changed

editoast/openapi.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -3340,13 +3340,18 @@ components:
33403340
- properties:
33413341
OperationalPointNotFound:
33423342
properties:
3343+
missing_ids:
3344+
items:
3345+
type: string
3346+
type: array
33433347
missing_uics:
33443348
items:
33453349
format: int64
33463350
type: integer
33473351
type: array
33483352
required:
33493353
- missing_uics
3354+
- missing_ids
33503355
type: object
33513356
required:
33523357
- OperationalPointNotFound
@@ -3420,6 +3425,17 @@ components:
34203425
- uic
34213426
- type
34223427
type: object
3428+
- properties:
3429+
id:
3430+
type: string
3431+
type:
3432+
enum:
3433+
- operational_point_id
3434+
type: string
3435+
required:
3436+
- id
3437+
- type
3438+
type: object
34233439
TimetableImportPathSchedule:
34243440
properties:
34253441
arrival_time:

editoast/src/models/infra_objects/operational_point.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::error::Result;
44
use crate::{schema::OperationalPoint, tables::infra_object_operational_point};
55
use derivative::Derivative;
6-
use diesel::sql_types::{Array, BigInt};
6+
use diesel::sql_types::{Array, BigInt, Text};
77
use diesel::{result::Error as DieselError, sql_query};
88
use diesel::{ExpressionMethods, QueryDsl};
99
use diesel_async::{AsyncPgConnection as PgConnection, RunQueryDsl};
@@ -38,4 +38,19 @@ impl OperationalPointModel {
3838
.load(conn)
3939
.await?)
4040
}
41+
42+
/// Retrieve a list of operational points from the database
43+
pub async fn retrieve_from_obj_ids(
44+
conn: &mut PgConnection,
45+
infra_id: i64,
46+
ids: &[String],
47+
) -> Result<Vec<Self>> {
48+
let query = "SELECT * FROM infra_object_operational_point
49+
WHERE infra_id = $1 AND infra_object_operational_point.obj_id = ANY($2)".to_string();
50+
Ok(sql_query(query)
51+
.bind::<BigInt, _>(infra_id)
52+
.bind::<Array<Text>, _>(ids)
53+
.load(conn)
54+
.await?)
55+
}
4156
}

0 commit comments

Comments
 (0)