Skip to content

Commit

Permalink
editoast: move identifier to editoast_common
Browse files Browse the repository at this point in the history
  • Loading branch information
hamz2a committed Apr 9, 2024
1 parent 37aa39e commit 940d62b
Show file tree
Hide file tree
Showing 37 changed files with 44 additions and 38 deletions.
2 changes: 2 additions & 0 deletions editoast/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions editoast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ editoast_common = { path = "./editoast_common" }
geos = { version = "8.3.1", features = ["json"] }
mvt = "0.9.0"
postgis_diesel = { version = "2.3.0", features = ["serde"] }
rand = "0.8.5"
rangemap = "1.5.1"
serde = "1.0.195"
serde_derive = "1.0.195"
serde_json = "1.0.115"
strum = { version = "0.26.2", features = ["derive"] }
thiserror = "1.0.58"
utoipa = { version = "4.2.0", features = ["actix_extras", "chrono", "uuid"] }
uuid = { version = "1.8.0", features = ["v4"] }

[dependencies]
# For batch dependcy updates see https://osrd.fr/en/docs/guides/contribute/batch-updating-dependencies/
Expand Down Expand Up @@ -72,7 +74,7 @@ paste = "1.0.14"
pathfinding = "4.9.1"
postgis_diesel.workspace = true
postgres-openssl = "0.5.0"
rand = "0.8.5"
rand.workspace = true
rangemap.workspace = true
redis = { version = "0.25.3", features = [
"cluster-async",
Expand All @@ -98,7 +100,7 @@ tracing-opentelemetry = "0.23.0"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
url = "2.5.0"
utoipa.workspace = true
uuid = { version = "1.8.0", features = ["v4"] }
uuid.workspace = true
validator = { version = "0.17.0", features = ["derive"] }

[dev-dependencies]
Expand Down
2 changes: 2 additions & 0 deletions editoast/editoast_common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ geos.workspace = true
iso8601 = "0.6.1"
mvt.workspace = true
postgis_diesel.workspace = true
rand.workspace = true
rangemap.workspace = true
serde.workspace = true
serde_derive.workspace = true
serde_json.workspace = true
thiserror.workspace = true
utoipa.workspace = true
uuid.workspace = true
File renamed without changes.
2 changes: 2 additions & 0 deletions editoast/editoast_common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ pub mod duration;
pub mod geo_json;
pub mod geometry;
mod hash_rounded_float;
mod identifier;
pub mod rangemap_utils;
pub mod schemas;

pub use duration::PositiveDuration;
pub use hash_rounded_float::hash_float;
pub use hash_rounded_float::hash_float_slice;
pub use identifier::Identifier;
2 changes: 1 addition & 1 deletion editoast/src/converters/generate_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use std::collections::HashMap;

use crate::schema::utils::Identifier;
use crate::schema::*;
use editoast_common::Identifier;

/* Part 1: type definitions */
// When building the graph, a node can be a trackEndPoint, a detector or a buffer stop
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/converters/osm_to_railjson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ mod tests {

use super::parse_osm;
use crate::converters::*;
use crate::schema::utils::Identifier;
use crate::schema::*;
use editoast_common::Identifier;
#[test]
fn convert_osm_to_railjson() {
let output = tempfile::NamedTempFile::new().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/converters/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use osmpbfreader::Node;
use tracing::error;
use tracing::warn;

use crate::schema::utils::Identifier;
use crate::schema::*;
use editoast_common::Identifier;

// Given an edge and a coordinate, returns the coordinates used to compute the angle
// It uses the nearest OpenStreetMap node, and the other as the the rails might do a loop
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/core/v2/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use serde::Deserialize;
use serde::Serialize;

use crate::core::{AsCoreRequest, Json};
use crate::schema::utils::Identifier;
use crate::schema::v2::trainschedule::MarginValue;
use crate::schema::v2::trainschedule::TrainScheduleOptions;
use crate::schema::v2::trainschedule::{Comfort, Distribution};
Expand All @@ -19,6 +18,7 @@ use crate::views::v2::train_schedule::Mrsp;
use crate::views::v2::train_schedule::ReportTrain;
use crate::RollingStockModel;
use derivative::Derivative;
use editoast_common::Identifier;
use std::hash::Hash;

#[derive(Debug, Serialize, Derivative)]
Expand Down
4 changes: 2 additions & 2 deletions editoast/src/infra_cache/graph.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::collections::HashMap;

use crate::infra_cache::InfraCache;
use crate::schema::utils::Identifier;
use crate::schema::SwitchCache;
use crate::schema::TrackEndpoint;
use editoast_common::Identifier;

#[derive(Default, Clone, Debug)]
pub struct Graph<'a> {
Expand Down Expand Up @@ -92,8 +92,8 @@ mod tests {
use crate::infra_cache::tests::create_small_infra_cache;
use crate::infra_cache::tests::create_track_endpoint;
use crate::infra_cache::InfraCache;
use crate::schema::utils::Identifier;
use crate::schema::Endpoint;
use editoast_common::Identifier;

#[test]
fn create_empty_graph() {
Expand Down
4 changes: 2 additions & 2 deletions editoast/src/infra_cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,6 @@ pub mod tests {
use crate::infra_cache::SwitchCache;
use crate::map::BoundingBox;
use crate::modelsv2::infra::tests::test_infra_transaction;
use crate::schema::utils::Identifier;
use crate::schema::utils::NonBlankString;
use crate::schema::ApplicableDirections;
use crate::schema::ApplicableDirectionsTrackRange;
Expand All @@ -761,6 +760,7 @@ pub mod tests {
use crate::schema::SwitchType;
use crate::schema::TrackEndpoint;
use crate::schema::Waypoint;
use editoast_common::Identifier;

#[actix_test]
async fn load_track_section() {
Expand Down Expand Up @@ -1283,11 +1283,11 @@ pub mod tests {
use crate::infra_cache::tests::create_switch_type_cache;
use crate::infra_cache::InfraCache;
use crate::infra_cache::InfraCacheEditoastError;
use crate::schema::utils::Identifier;
use crate::schema::Direction::StartToStop;
use crate::schema::ObjectType;
use crate::schema::TrackEndpoint;
use crate::schema::Waypoint::BufferStop;
use editoast_common::Identifier;

#[test]
fn track_section() {
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/schema/buffer_stop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use diesel::sql_types::Text;
use serde::Deserialize;
use serde::Serialize;

use super::utils::Identifier;
use super::OSRDIdentified;
use super::OSRDTyped;
use super::ObjectType;
use crate::infra_cache::Cache;
use crate::infra_cache::ObjectCache;
use editoast_common::Identifier;

#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)]
#[serde(deny_unknown_fields)]
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/schema/detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use diesel::sql_types::Text;
use serde::Deserialize;
use serde::Serialize;

use super::utils::Identifier;
use super::OSRDIdentified;
use super::OSRDTyped;
use super::ObjectType;
use crate::infra_cache::Cache;
use crate::infra_cache::ObjectCache;
use editoast_common::Identifier;

#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)]
#[serde(deny_unknown_fields)]
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/schema/electrification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use derivative::Derivative;
use serde::Deserialize;
use serde::Serialize;

use super::utils::Identifier;
use super::utils::NonBlankString;
use super::ApplicableDirectionsTrackRange;
use super::OSRDIdentified;
use super::OSRDTyped;
use super::ObjectType;
use crate::infra_cache::Cache;
use crate::infra_cache::ObjectCache;
use editoast_common::Identifier;
#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)]
#[serde(deny_unknown_fields)]
#[derivative(Default)]
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ use strum::Display;
use strum::EnumIter;
use utoipa::ToSchema;

use self::utils::Identifier;
use self::utils::NonBlankString;
use editoast_common::Identifier;

editoast_common::schemas! {
ObjectType,
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/schema/neutral_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use derivative::Derivative;
use serde::Deserialize;
use serde::Serialize;

use super::utils::Identifier;
use super::DirectionalTrackRange;
use super::OSRDIdentified;
use super::OSRDTyped;
use super::ObjectType;
use super::Sign;
use editoast_common::Identifier;

/// Neutral sections are portions of track where trains aren't allowed to pull power from electrifications. They have to rely on inertia to cross such sections.
///
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/schema/operational_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use serde::Deserialize;
use serde::Serialize;
use utoipa::ToSchema;

use super::utils::Identifier;
use super::utils::NonBlankString;
use super::OSRDIdentified;
use super::OSRDTyped;
Expand All @@ -12,6 +11,7 @@ use crate::infra_cache::Cache;
use crate::infra_cache::ObjectCache;
use crate::modelsv2::OperationalPointModel;
use crate::schema::TrackOffset;
use editoast_common::Identifier;

#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, ToSchema)]
#[serde(deny_unknown_fields)]
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/schema/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use serde::Serialize;
use super::Direction;
use super::DirectionalTrackRange;
use super::Endpoint;
use super::Identifier;
use super::OSRDIdentified;
use super::OSRDTyped;
use super::ObjectType;
Expand All @@ -17,6 +16,7 @@ use crate::infra_cache::Cache;
use crate::infra_cache::Graph;
use crate::infra_cache::InfraCache;
use crate::infra_cache::ObjectCache;
use editoast_common::Identifier;

#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/schema/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use diesel_json::Json as DieselJson;
use serde::Deserialize;
use serde::Serialize;

use super::utils::Identifier;
use super::utils::NonBlankString;
use super::Direction;
use super::OSRDIdentified;
Expand All @@ -17,6 +16,7 @@ use super::ObjectType;
use super::Side;
use crate::infra_cache::Cache;
use crate::infra_cache::ObjectCache;
use editoast_common::Identifier;

#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)]
#[serde(deny_unknown_fields)]
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/schema/speed_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use derivative::Derivative;
use serde::Deserialize;
use serde::Serialize;

use super::utils::Identifier;
use super::utils::NonBlankString;
use super::ApplicableDirectionsTrackRange;
use super::OSRDIdentified;
Expand All @@ -13,6 +12,7 @@ use super::ObjectType;
use super::Sign;
use crate::infra_cache::Cache;
use crate::infra_cache::ObjectCache;
use editoast_common::Identifier;

#[derive(Debug, Derivative, Clone, Serialize, PartialEq, Copy)]
pub struct Speed(pub f64);
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/schema/switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use derivative::Derivative;
use serde::Deserialize;
use serde::Serialize;

use super::utils::Identifier;
use super::utils::NonBlankString;
use super::OSRDIdentified;
use super::OSRDTyped;
use super::ObjectType;
use super::TrackEndpoint;
use crate::infra_cache::Cache;
use crate::infra_cache::ObjectCache;
use editoast_common::Identifier;

#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)]
#[serde(deny_unknown_fields)]
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/schema/switch_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use derivative::Derivative;
use serde::Deserialize;
use serde::Serialize;

use super::utils::Identifier;
use super::OSRDIdentified;
use super::OSRDTyped;
use super::ObjectType;
use crate::infra_cache::Cache;
use crate::infra_cache::ObjectCache;
use editoast_common::Identifier;

type StaticPortConnection = (&'static str, &'static str);
type StaticMap = (&'static str, &'static [StaticPortConnection]);
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/schema/track_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use geos::geojson::Value::LineString;
use serde::Deserialize;
use serde::Serialize;

use super::utils::Identifier;
use super::utils::NonBlankString;
use super::Endpoint;
use super::OSRDIdentified;
Expand All @@ -15,6 +14,7 @@ use super::TrackEndpoint;
use crate::infra_cache::Cache;
use crate::infra_cache::ObjectCache;
use crate::map::BoundingBox;
use editoast_common::Identifier;

#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)]
#[serde(deny_unknown_fields)]
Expand Down
2 changes: 0 additions & 2 deletions editoast/src/schema/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
mod identifier;
mod non_blank_string;

use editoast_common::geometry;
pub use identifier::Identifier;
pub use non_blank_string::NonBlankString;

editoast_common::schemas! {
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/schema/v2/trainschedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use serde::Serialize;
use strum::FromRepr;
use utoipa::ToSchema;

use crate::schema::utils::Identifier;
use crate::schema::utils::NonBlankString;
use crate::schema::TrackOffset;
use editoast_common::Identifier;
use editoast_common::PositiveDuration;

#[derive(Debug, Default, Clone, Serialize, ToSchema)]
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/views/infra/auto_fixes/electrifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ mod tests {
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::operation::Operation;
use crate::infra_cache::ObjectCache;
use crate::schema::utils::Identifier;
use crate::schema::ApplicableDirections;
use crate::schema::ApplicableDirectionsTrackRange;
use crate::schema::Electrification;
use crate::schema::InfraError;
use crate::schema::OSRDObject as _;
use crate::schema::ObjectRef;
use crate::schema::ObjectType;
use editoast_common::Identifier;

#[test]
fn invalid_refs_ordered_electrification() {
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/views/infra/auto_fixes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ mod tests {
use crate::infra_cache::operation::Operation;
use crate::infra_cache::operation::RailjsonObject;
use crate::infra_cache::InfraCacheEditoastError;
use crate::schema::utils::Identifier;
use crate::schema::ApplicableDirectionsTrackRange;
use crate::schema::BufferStop;
use crate::schema::BufferStopCache;
Expand All @@ -357,6 +356,7 @@ mod tests {
use crate::schema::Waypoint;
use crate::views::pagination::PaginatedResponse;
use crate::views::tests::create_test_service;
use editoast_common::Identifier;

async fn get_infra_cache(infra: &Infra) -> InfraCache {
InfraCache::load(&mut db_pool().get().await.unwrap(), infra)
Expand Down
Loading

0 comments on commit 940d62b

Please sign in to comment.