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

editoast: move schema/operation to editoast::infra_cache #7089

Merged
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
5 changes: 3 additions & 2 deletions editoast/src/generated_data/buffer_stop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use super::utils::InvolvedObjects;
use super::GeneratedData;
use crate::diesel::ExpressionMethods;
use crate::error::Result;
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::InfraCache;
use crate::schema::ObjectType;
use crate::tables::infra_layer_buffer_stop::dsl;
Expand All @@ -35,8 +36,8 @@ impl GeneratedData for BufferStopLayer {
async fn update(
conn: &mut PgConnection,
infra: i64,
operations: &[crate::schema::operation::CacheOperation],
infra_cache: &crate::infra_cache::InfraCache,
operations: &[CacheOperation],
infra_cache: &InfraCache,
) -> Result<()> {
let involved_objects =
InvolvedObjects::from_operations(operations, infra_cache, ObjectType::BufferStop);
Expand Down
5 changes: 3 additions & 2 deletions editoast/src/generated_data/detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use super::utils::InvolvedObjects;
use super::GeneratedData;
use crate::diesel::ExpressionMethods;
use crate::error::Result;
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::InfraCache;
use crate::schema::ObjectType;
use crate::tables::infra_layer_detector::dsl;
Expand All @@ -35,8 +36,8 @@ impl GeneratedData for DetectorLayer {
async fn update(
conn: &mut PgConnection,
infra: i64,
operations: &[crate::schema::operation::CacheOperation],
infra_cache: &crate::infra_cache::InfraCache,
operations: &[CacheOperation],
infra_cache: &InfraCache,
) -> Result<()> {
let involved_objects =
InvolvedObjects::from_operations(operations, infra_cache, ObjectType::Detector);
Expand Down
5 changes: 3 additions & 2 deletions editoast/src/generated_data/electrification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use super::utils::InvolvedObjects;
use super::GeneratedData;
use crate::diesel::ExpressionMethods;
use crate::error::Result;
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::InfraCache;
use crate::schema::ObjectType;
use crate::tables::infra_layer_electrification::dsl;
Expand Down Expand Up @@ -39,8 +40,8 @@ impl GeneratedData for ElectrificationLayer {
async fn update(
conn: &mut PgConnection,
infra: i64,
operations: &[crate::schema::operation::CacheOperation],
infra_cache: &crate::infra_cache::InfraCache,
operations: &[CacheOperation],
infra_cache: &InfraCache,
) -> Result<()> {
let involved_objects =
InvolvedObjects::from_operations(operations, infra_cache, ObjectType::Electrification);
Expand Down
3 changes: 2 additions & 1 deletion editoast/src/generated_data/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use tracing::warn;

use super::GeneratedData;
use crate::error::Result;
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::Graph;
use crate::infra_cache::InfraCache;
use crate::infra_cache::ObjectCache;
Expand Down Expand Up @@ -413,7 +414,7 @@ impl GeneratedData for ErrorLayer {
async fn update(
conn: &mut PgConnection,
infra_id: i64,
_operations: &[crate::schema::operation::CacheOperation],
_operations: &[CacheOperation],
infra_cache: &InfraCache,
) -> Result<()> {
// Generate already act like an update
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/generated_data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ use tracing::debug;
use track_section::TrackSectionLayer;

use crate::error::Result;
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::InfraCache;
use crate::schema::operation::CacheOperation;

/// This trait define how a generated data table should be handled
#[async_trait]
Expand Down
5 changes: 3 additions & 2 deletions editoast/src/generated_data/neutral_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use diesel_async::RunQueryDsl;

use super::GeneratedData;
use crate::error::Result;
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::InfraCache;

pub struct NeutralSectionLayer;
Expand All @@ -27,8 +28,8 @@ impl GeneratedData for NeutralSectionLayer {
async fn update(
_conn: &mut PgConnection,
_infra: i64,
_operations: &[crate::schema::operation::CacheOperation],
_infra_cache: &crate::infra_cache::InfraCache,
_operations: &[CacheOperation],
_infra_cache: &InfraCache,
) -> Result<()> {
// TODO: we don't manage the update of the neutral_section layer for the moment
Ok(())
Expand Down
5 changes: 3 additions & 2 deletions editoast/src/generated_data/neutral_sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use super::utils::InvolvedObjects;
use super::GeneratedData;
use crate::diesel::ExpressionMethods;
use crate::error::Result;
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::InfraCache;
use crate::schema::ObjectType;
use crate::tables::infra_layer_neutral_sign::dsl;
Expand All @@ -35,8 +36,8 @@ impl GeneratedData for NeutralSignLayer {
async fn update(
conn: &mut PgConnection,
infra: i64,
operations: &[crate::schema::operation::CacheOperation],
infra_cache: &crate::infra_cache::InfraCache,
operations: &[CacheOperation],
infra_cache: &InfraCache,
) -> Result<()> {
let involved_objects =
InvolvedObjects::from_operations(operations, infra_cache, ObjectType::NeutralSection);
Expand Down
5 changes: 3 additions & 2 deletions editoast/src/generated_data/operational_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use super::utils::InvolvedObjects;
use super::GeneratedData;
use crate::diesel::ExpressionMethods;
use crate::error::Result;
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::InfraCache;
use crate::schema::ObjectType;
use crate::tables::infra_layer_operational_point::dsl;
Expand All @@ -35,8 +36,8 @@ impl GeneratedData for OperationalPointLayer {
async fn update(
conn: &mut PgConnection,
infra: i64,
operations: &[crate::schema::operation::CacheOperation],
infra_cache: &crate::infra_cache::InfraCache,
operations: &[CacheOperation],
infra_cache: &InfraCache,
) -> Result<()> {
let involved_objects =
InvolvedObjects::from_operations(operations, infra_cache, ObjectType::OperationalPoint);
Expand Down
5 changes: 3 additions & 2 deletions editoast/src/generated_data/psl_sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use super::utils::InvolvedObjects;
use super::GeneratedData;
use crate::diesel::ExpressionMethods;
use crate::error::Result;
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::InfraCache;
use crate::schema::ObjectType;
use crate::tables::infra_layer_psl_sign::dsl;
Expand All @@ -35,8 +36,8 @@ impl GeneratedData for PSLSignLayer {
async fn update(
conn: &mut PgConnection,
infra: i64,
operations: &[crate::schema::operation::CacheOperation],
infra_cache: &crate::infra_cache::InfraCache,
operations: &[CacheOperation],
infra_cache: &InfraCache,
) -> Result<()> {
let involved_objects =
InvolvedObjects::from_operations(operations, infra_cache, ObjectType::SpeedSection);
Expand Down
5 changes: 3 additions & 2 deletions editoast/src/generated_data/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::diesel::ExpressionMethods;
use crate::error::Result;
use crate::generated_data::sprite_config::SpriteConfig;
use crate::generated_data::sprite_config::SpriteConfigs;
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::InfraCache;
use crate::schema::LogicalSignal;
use crate::schema::ObjectType;
Expand Down Expand Up @@ -108,8 +109,8 @@ impl GeneratedData for SignalLayer {
async fn update(
conn: &mut PgConnection,
infra: i64,
operations: &[crate::schema::operation::CacheOperation],
infra_cache: &crate::infra_cache::InfraCache,
operations: &[CacheOperation],
infra_cache: &InfraCache,
) -> Result<()> {
use diesel_async::RunQueryDsl;

Expand Down
5 changes: 3 additions & 2 deletions editoast/src/generated_data/speed_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use super::utils::InvolvedObjects;
use super::GeneratedData;
use crate::diesel::ExpressionMethods;
use crate::error::Result;
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::InfraCache;
use crate::schema::ObjectType;
use crate::tables::infra_layer_speed_section::dsl;
Expand All @@ -35,8 +36,8 @@ impl GeneratedData for SpeedSectionLayer {
async fn update(
conn: &mut PgConnection,
infra: i64,
operations: &[crate::schema::operation::CacheOperation],
infra_cache: &crate::infra_cache::InfraCache,
operations: &[CacheOperation],
infra_cache: &InfraCache,
) -> Result<()> {
let involved_objects =
InvolvedObjects::from_operations(operations, infra_cache, ObjectType::SpeedSection);
Expand Down
5 changes: 3 additions & 2 deletions editoast/src/generated_data/switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use diesel_async::RunQueryDsl;
use super::utils::InvolvedObjects;
use super::GeneratedData;
use crate::error::Result;
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::InfraCache;
use crate::schema::ObjectType;

Expand All @@ -31,8 +32,8 @@ impl GeneratedData for SwitchLayer {
async fn update(
conn: &mut PgConnection,
infra: i64,
operations: &[crate::schema::operation::CacheOperation],
infra_cache: &crate::infra_cache::InfraCache,
operations: &[CacheOperation],
infra_cache: &InfraCache,
) -> Result<()> {
let involved_objects =
InvolvedObjects::from_operations(operations, infra_cache, ObjectType::Switch);
Expand Down
5 changes: 3 additions & 2 deletions editoast/src/generated_data/track_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use super::utils::InvolvedObjects;
use super::GeneratedData;
use crate::diesel::ExpressionMethods;
use crate::error::Result;
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::InfraCache;
use crate::schema::ObjectType;
use crate::tables::infra_layer_track_section::dsl;
Expand All @@ -35,8 +36,8 @@ impl GeneratedData for TrackSectionLayer {
async fn update(
conn: &mut PgConnection,
infra: i64,
operations: &[crate::schema::operation::CacheOperation],
infra_cache: &crate::infra_cache::InfraCache,
operations: &[CacheOperation],
infra_cache: &InfraCache,
) -> Result<()> {
let involved_objects =
InvolvedObjects::from_operations(operations, infra_cache, ObjectType::TrackSection);
Expand Down
4 changes: 2 additions & 2 deletions editoast/src/generated_data/utils.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::HashSet;

use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::InfraCache;
use crate::infra_cache::ObjectCache;
use crate::schema::operation::CacheOperation;
use crate::schema::OSRDIdentified;
use crate::schema::OSRDObject;
use crate::schema::ObjectType;
Expand Down Expand Up @@ -63,9 +63,9 @@ mod test {
use std::collections::HashSet;

use super::InvolvedObjects;
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::tests::create_small_infra_cache;
use crate::infra_cache::ObjectCache;
use crate::schema::operation::CacheOperation;
use crate::schema::DetectorCache;
use crate::schema::ObjectRef;
use crate::schema::ObjectType;
Expand Down
25 changes: 13 additions & 12 deletions editoast/src/infra_cache/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod graph;
pub mod operation;

use std::collections::hash_map::Entry;
use std::collections::HashMap;
Expand All @@ -24,11 +25,11 @@ use itertools::Itertools as _;
use thiserror::Error;

use crate::error::Result;
use crate::infra_cache::operation::CacheOperation;
use crate::infra_cache::operation::RailjsonObject;
use crate::map::BoundingBox;
use crate::modelsv2::railjson::find_all_schemas;
use crate::modelsv2::Infra;
use crate::schema::operation::CacheOperation;
use crate::schema::operation::RailjsonObject;
use crate::schema::*;

/// Contains infra cached data used to generate layers and errors
Expand Down Expand Up @@ -729,20 +730,20 @@ pub mod tests {
use super::OperationalPointCache;
use super::SignalCache;
use super::TrackSectionCache;
use crate::infra_cache::operation::create::tests::create_buffer_stop;
use crate::infra_cache::operation::create::tests::create_detector;
use crate::infra_cache::operation::create::tests::create_electrification;
use crate::infra_cache::operation::create::tests::create_op;
use crate::infra_cache::operation::create::tests::create_route;
use crate::infra_cache::operation::create::tests::create_signal;
use crate::infra_cache::operation::create::tests::create_speed;
use crate::infra_cache::operation::create::tests::create_switch;
use crate::infra_cache::operation::create::tests::create_switch_type;
use crate::infra_cache::operation::create::tests::create_track;
use crate::infra_cache::InfraCache;
use crate::infra_cache::SwitchCache;
use crate::map::BoundingBox;
use crate::modelsv2::infra::tests::test_infra_transaction;
use crate::schema::operation::create::tests::create_buffer_stop;
use crate::schema::operation::create::tests::create_detector;
use crate::schema::operation::create::tests::create_electrification;
use crate::schema::operation::create::tests::create_op;
use crate::schema::operation::create::tests::create_route;
use crate::schema::operation::create::tests::create_signal;
use crate::schema::operation::create::tests::create_speed;
use crate::schema::operation::create::tests::create_switch;
use crate::schema::operation::create::tests::create_switch_type;
use crate::schema::operation::create::tests::create_track;
use crate::schema::utils::Identifier;
use crate::schema::utils::NonBlankString;
use crate::schema::ApplicableDirections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ pub mod tests {
use diesel_async::scoped_futures::ScopedFutureExt;
use diesel_async::AsyncPgConnection as PgConnection;

use crate::infra_cache::operation::create::apply_create_operation;
use crate::infra_cache::operation::create::RailjsonObject;
use crate::modelsv2::infra::tests::test_infra_transaction;
use crate::schema::operation::create::apply_create_operation;
use crate::schema::operation::create::RailjsonObject;
use crate::schema::BufferStop;
use crate::schema::Detector;
use crate::schema::Electrification;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ mod tests {
use diesel_async::scoped_futures::ScopedFutureExt;
use diesel_async::RunQueryDsl;

use crate::infra_cache::operation::create::tests::create_buffer_stop;
use crate::infra_cache::operation::create::tests::create_detector;
use crate::infra_cache::operation::create::tests::create_electrification;
use crate::infra_cache::operation::create::tests::create_op;
use crate::infra_cache::operation::create::tests::create_route;
use crate::infra_cache::operation::create::tests::create_signal;
use crate::infra_cache::operation::create::tests::create_speed;
use crate::infra_cache::operation::create::tests::create_switch;
use crate::infra_cache::operation::create::tests::create_track;
use crate::infra_cache::operation::delete::DeleteOperation;
use crate::modelsv2::infra::tests::test_infra_transaction;
use crate::schema::operation::create::tests::create_buffer_stop;
use crate::schema::operation::create::tests::create_detector;
use crate::schema::operation::create::tests::create_electrification;
use crate::schema::operation::create::tests::create_op;
use crate::schema::operation::create::tests::create_route;
use crate::schema::operation::create::tests::create_signal;
use crate::schema::operation::create::tests::create_speed;
use crate::schema::operation::create::tests::create_switch;
use crate::schema::operation::create::tests::create_track;
use crate::schema::operation::delete::DeleteOperation;
use crate::schema::OSRDIdentified;
use crate::schema::OSRDObject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use serde_json::Value;

use super::OperationError;
use crate::error::Result;
use crate::infra_cache::operation::RailjsonObject;
use crate::modelsv2::get_table;
use crate::schema::operation::RailjsonObject;
use crate::schema::OSRDIdentified;
use crate::schema::ObjectType;

Expand Down Expand Up @@ -129,12 +129,12 @@ mod tests {

use super::UpdateOperation;
use crate::error::EditoastError;
use crate::infra_cache::operation::create::tests::create_signal;
use crate::infra_cache::operation::create::tests::create_speed;
use crate::infra_cache::operation::create::tests::create_switch;
use crate::infra_cache::operation::create::tests::create_track;
use crate::infra_cache::operation::OperationError;
use crate::modelsv2::infra::tests::test_infra_transaction;
use crate::schema::operation::create::tests::create_signal;
use crate::schema::operation::create::tests::create_speed;
use crate::schema::operation::create::tests::create_switch;
use crate::schema::operation::create::tests::create_track;
use crate::schema::operation::OperationError;
use crate::schema::OSRDIdentified;
use crate::schema::ObjectType;

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 @@ -5,7 +5,6 @@ mod electrification;
mod errors;
mod geo_json;
mod neutral_section;
pub mod operation;
pub mod operational_point;
mod railjson;
pub mod rolling_stock;
Expand Down Expand Up @@ -63,6 +62,7 @@ cfg_if! {
}
}

use crate::infra_cache::operation;
use derivative::Derivative;
use enum_map::Enum;
use serde::Deserialize;
Expand Down
Loading
Loading