Skip to content

Commit

Permalink
Adding OperationalPointIdLocation as location for POST `/timetable/…
Browse files Browse the repository at this point in the history
…{id}`
  • Loading branch information
bloussou committed Feb 2, 2024
1 parent 472bff2 commit 2115168
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 38 deletions.
16 changes: 16 additions & 0 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3340,13 +3340,18 @@ components:
- properties:
OperationalPointNotFound:
properties:
missing_ids:
items:
type: string
type: array
missing_uics:
items:
format: int64
type: integer
type: array
required:
- missing_uics
- missing_ids
type: object
required:
- OperationalPointNotFound
Expand Down Expand Up @@ -3420,6 +3425,17 @@ components:
- uic
- type
type: object
- properties:
id:
type: string
type:
enum:
- operational_point_id
type: string
required:
- id
- type
type: object
TimetableImportPathSchedule:
properties:
arrival_time:
Expand Down
17 changes: 16 additions & 1 deletion editoast/src/models/infra_objects/operational_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::error::Result;
use crate::{schema::OperationalPoint, tables::infra_object_operational_point};
use derivative::Derivative;
use diesel::sql_types::{Array, BigInt};
use diesel::sql_types::{Array, BigInt, Text};
use diesel::{result::Error as DieselError, sql_query};
use diesel::{ExpressionMethods, QueryDsl};
use diesel_async::{AsyncPgConnection as PgConnection, RunQueryDsl};
Expand Down Expand Up @@ -38,4 +38,19 @@ impl OperationalPointModel {
.load(conn)
.await?)
}

/// Retrieve a list of operational points from the database
pub async fn retrieve_from_obj_ids(
conn: &mut PgConnection,
infra_id: i64,
ids: &[String],
) -> Result<Vec<Self>> {
let query = "SELECT * FROM infra_object_operational_point
WHERE infra_id = $1 AND infra_object_operational_point.obj_id = ANY($2)".to_string();
Ok(sql_query(query)
.bind::<BigInt, _>(infra_id)
.bind::<Array<Text>, _>(ids)
.load(conn)
.await?)
}
}
Loading

0 comments on commit 2115168

Please sign in to comment.