Skip to content

Commit 3a85ee7

Browse files
committed
Adding OperationalPointIdLocation as location for POST /timetable/{id}
1 parent a235b0d commit 3a85ee7

File tree

4 files changed

+203
-45
lines changed

4 files changed

+203
-45
lines changed

editoast/openapi.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -3324,13 +3324,18 @@ components:
33243324
- properties:
33253325
OperationalPointNotFound:
33263326
properties:
3327+
missing_ids:
3328+
items:
3329+
type: string
3330+
type: array
33273331
missing_uics:
33283332
items:
33293333
format: int64
33303334
type: integer
33313335
type: array
33323336
required:
33333337
- missing_uics
3338+
- missing_ids
33343339
type: object
33353340
required:
33363341
- OperationalPointNotFound
@@ -3404,6 +3409,17 @@ components:
34043409
- uic
34053410
- type
34063411
type: object
3412+
- properties:
3413+
id:
3414+
type: string
3415+
type:
3416+
enum:
3417+
- operational_point_id
3418+
type: string
3419+
required:
3420+
- id
3421+
- type
3422+
type: object
34073423
TimetableImportPathSchedule:
34083424
properties:
34093425
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)