Skip to content

Commit

Permalink
editoast: remove unused endpoint GET /infra/cache_status
Browse files Browse the repository at this point in the history
  • Loading branch information
leovalais committed May 29, 2024
1 parent 2e364ae commit 0479343
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions editoast/src/views/infra/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ use actix_web::web::Data;
use actix_web::web::Json;
use actix_web::web::Path;
use actix_web::web::Query;
use actix_web::Either;
use actix_web::HttpResponse;
use actix_web::Responder;
use chashmap::CHashMap;
use editoast_derive::EditoastError;
use serde::Deserialize;
use serde::Serialize;
use std::collections::HashMap;
use std::ops::DerefMut as _;
use std::sync::Arc;
use thiserror::Error;
use utoipa::IntoParams;
Expand Down Expand Up @@ -97,7 +95,6 @@ pub fn infra_routes() -> impl HttpServiceFactory {
list,
create,
refresh,
cache_status,
get_all_voltages,
railjson::railjson_routes(),
))
Expand Down Expand Up @@ -628,31 +625,6 @@ async fn load(
Ok(HttpResponse::NoContent().finish())
}

#[derive(Debug, Default, Deserialize)]
pub struct StatePayload {
infra: Option<i64>,
}

#[get("/cache_status")]
async fn cache_status(
payload: Either<Json<StatePayload>, ()>,
db_pool: Data<DbConnectionPool>,
core: Data<CoreClient>,
) -> Result<Json<HashMap<String, InfraStateResponse>>> {
if let Either::Left(Json(StatePayload {
infra: Some(infra_id),
})) = payload
{
if !Infra::exists(db_pool.get().await?.deref_mut(), infra_id).await? {
return Err(InfraApiError::NotFound { infra_id }.into());
}
let infra_state = fetch_infra_state(infra_id, core.as_ref()).await?;
Ok(Json(HashMap::from([(infra_id.to_string(), infra_state)])))
} else {
Ok(Json(fetch_all_infra_states(core.as_ref()).await?))
}
}

/// Builds a Core cache_status request, runs it
pub async fn fetch_infra_state(infra_id: i64, core: &CoreClient) -> Result<InfraStateResponse> {
Ok(InfraStateRequest {
Expand Down

0 comments on commit 0479343

Please sign in to comment.