-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
editoast, front: import, filter and send to core temporary speed limits
- Add a temporary_speed_limits table creation migration script. - Add a temporary speed limit creation endpoint. - Add the active temporary speed limits which are active during an stdcm search to the stdcm request sent to core. Signed-off-by: Sh099078 <[email protected]>
- Loading branch information
Showing
19 changed files
with
687 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DROP TABLE temporary_speed_limit; | ||
DROP TABLE temporary_speed_limit_group; |
19 changes: 19 additions & 0 deletions
19
editoast/migrations/2024-09-06-153144_add_ltv_table/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
CREATE TABLE temporary_speed_limit_group( | ||
id int8 PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, | ||
creation_date timestamptz NOT NULL, | ||
name varchar(255) NOT NULL UNIQUE | ||
); | ||
|
||
CREATE TABLE temporary_speed_limit ( | ||
id int8 PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, | ||
start_date_time timestamptz NOT NULL, | ||
end_date_time timestamptz NOT NULL, | ||
speed_limit float8 NOT NULL, | ||
track_ranges jsonb NOT NULL, | ||
obj_id VARCHAR(255) NOT NULL, | ||
temporary_speed_limit_group_id int8 NOT NULL REFERENCES temporary_speed_limit_group(id) ON DELETE CASCADE, | ||
CONSTRAINT valid_time_period CHECK (start_date_time < end_date_time) | ||
); | ||
|
||
CREATE INDEX "temporary_speed_limit_date_time" ON "temporary_speed_limit" ("start_date_time"); | ||
CREATE INDEX "temporary_speed_limit_end_date_time" ON "temporary_speed_limit" ("end_date_time"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use chrono::NaiveDateTime; | ||
use editoast_derive::Model; | ||
use editoast_models::tables::{temporary_speed_limit, temporary_speed_limit_group}; | ||
use editoast_schemas::infra::DirectionalTrackRange; | ||
use serde::Serialize; | ||
|
||
use crate::core::stdcm::TemporarySpeedLimit as CoreTemporarySpeedLimit; | ||
|
||
#[derive(Debug, Clone, Model)] | ||
#[model(table = temporary_speed_limit_group)] | ||
#[model(gen(ops = crd, batch_ops = c, list))] | ||
pub struct TemporarySpeedLimitGroup { | ||
pub id: i64, | ||
pub creation_date: NaiveDateTime, | ||
pub name: String, | ||
} | ||
|
||
#[derive(Debug, Serialize, Clone, Model)] | ||
#[model(table = temporary_speed_limit)] | ||
#[model(gen(ops = cr, batch_ops = c, list))] | ||
pub struct TemporarySpeedLimit { | ||
pub id: i64, | ||
pub start_date_time: NaiveDateTime, | ||
pub end_date_time: NaiveDateTime, | ||
pub speed_limit: f64, | ||
#[model(json)] | ||
pub track_ranges: Vec<DirectionalTrackRange>, | ||
pub obj_id: String, | ||
pub temporary_speed_limit_group_id: i64, | ||
} | ||
|
||
impl From<TemporarySpeedLimit> for CoreTemporarySpeedLimit { | ||
fn from(value: TemporarySpeedLimit) -> Self { | ||
CoreTemporarySpeedLimit { | ||
speed_limit: value.speed_limit, | ||
track_ranges: value | ||
.track_ranges | ||
.into_iter() | ||
.map(|track_range| track_range.into()) | ||
.collect(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.