Skip to content

Commit

Permalink
editoast: replace infra by infra_id in refresh_all
Browse files Browse the repository at this point in the history
  • Loading branch information
hamz2a authored and woshilapin committed Jul 10, 2024
1 parent b01384d commit 54df292
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions editoast/src/generated_data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,38 +86,39 @@ pub trait GeneratedData {
}

/// Refresh all the generated data of a given infra
#[tracing::instrument(level = "debug", skip_all, fields(infra_id))]
pub async fn refresh_all(
db_pool: Arc<DbConnectionPoolV2>,
infra: i64,
infra_id: i64,
infra_cache: &InfraCache,
) -> Result<()> {
// The other layers depend on track section layer.
// We must wait until its completion before running the other requests in parallel
TrackSectionLayer::refresh_pool(db_pool.clone(), infra, infra_cache).await?;
debug!(infra_id = infra, "Infra: track section layer is generated");
TrackSectionLayer::refresh_pool(db_pool.clone(), infra_id, infra_cache).await?;
debug!("⚙️ Infra {infra_id}: track section layer is generated");
// The analyze step significantly improves the performance when importing and generating together
// It doesn’t seem to make a different when the generation step is ran separately
// It isn’t clear why without analyze the Postgres server seems to run at 100% without halting
sql_query("analyze")
.execute(db_pool.get().await?.deref_mut())
.await?;
debug!("⚙️ Infra {infra}: database analyzed");
debug!("⚙️ Infra {infra_id}: database analyzed");
futures::try_join!(
SpeedSectionLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
SignalLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
SwitchLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
BufferStopLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
ElectrificationLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
DetectorLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
OperationalPointLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
PSLSignLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
NeutralSectionLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
NeutralSignLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
SpeedSectionLayer::refresh_pool(db_pool.clone(), infra_id, infra_cache),
SignalLayer::refresh_pool(db_pool.clone(), infra_id, infra_cache),
SwitchLayer::refresh_pool(db_pool.clone(), infra_id, infra_cache),
BufferStopLayer::refresh_pool(db_pool.clone(), infra_id, infra_cache),
ElectrificationLayer::refresh_pool(db_pool.clone(), infra_id, infra_cache),
DetectorLayer::refresh_pool(db_pool.clone(), infra_id, infra_cache),
OperationalPointLayer::refresh_pool(db_pool.clone(), infra_id, infra_cache),
PSLSignLayer::refresh_pool(db_pool.clone(), infra_id, infra_cache),
NeutralSectionLayer::refresh_pool(db_pool.clone(), infra_id, infra_cache),
NeutralSignLayer::refresh_pool(db_pool.clone(), infra_id, infra_cache),
)?;
debug!("⚙️ Infra {infra}: object layers is generated");
debug!("⚙️ Infra {infra_id}: object layers is generated");
// The error layer depends on the other layers and must be executed at the end.
ErrorLayer::refresh_pool(db_pool.clone(), infra, infra_cache).await?;
debug!("⚙️ Infra {infra}: errors layer is generated");
ErrorLayer::refresh_pool(db_pool.clone(), infra_id, infra_cache).await?;
debug!("⚙️ Infra {infra_id}: errors layer is generated");
Ok(())
}

Expand Down

0 comments on commit 54df292

Please sign in to comment.