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

Adding OperationalPointIdLocation as location for POST /timetable/{id} #6466

Merged
merged 1 commit into from
Feb 2, 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
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
Loading