Skip to content

Commit

Permalink
returns if in_use as well
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderManich committed Nov 28, 2023
1 parent a0aa8b4 commit 08b154e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Ecdar-ProtoBuf
Submodule Ecdar-ProtoBuf updated 2 files
+13 −0 api.proto
+1 −1 services.proto
21 changes: 16 additions & 5 deletions src/api/ecdar_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ use super::server::server::{
get_auth_token_request::{user_credentials, UserCredentials},
CreateAccessRequest, CreateModelRequest, CreateModelResponse, CreateQueryRequest,
CreateUserRequest, DeleteAccessRequest, DeleteModelRequest, DeleteQueryRequest,
GetAuthTokenRequest, GetAuthTokenResponse, GetModelRequest, GetModelResponse, Query,
QueryRequest, QueryResponse, SimulationStartRequest, SimulationStepRequest,
SimulationStepResponse, UpdateAccessRequest, UpdateQueryRequest, UpdateUserRequest,
UserTokenResponse,
GetAuthTokenRequest, GetAuthTokenResponse, GetModelRequest, GetModelResponse,
ListAccessInfoResponse, Query, QueryRequest, QueryResponse, SimulationStartRequest,
SimulationStepRequest, SimulationStepResponse, UpdateAccessRequest, UpdateQueryRequest,
UpdateUserRequest, UserTokenResponse,
};

use crate::database::{
Expand Down Expand Up @@ -165,6 +165,13 @@ impl EcdarApi for ConcreteEcdarApi {
owner_id: model.owner_id,
};

let in_use = match self.in_use_context.get_by_id(model_id).await {
Ok(in_use) => {
matches!(in_use, Some(_in_use))
}
Err(err) => return Err(Status::new(Code::Internal, err.to_string())),
};

let queries = self
.query_context
.get_all_by_model_id(model_id)
Expand All @@ -188,6 +195,7 @@ impl EcdarApi for ConcreteEcdarApi {
Ok(Response::new(GetModelResponse {
model: Some(model),
queries,
in_use,
}))
}

Expand Down Expand Up @@ -229,7 +237,10 @@ impl EcdarApi for ConcreteEcdarApi {
todo!()
}

async fn list_models_info(&self, _request: Request<()>) -> Result<Response<()>, Status> {
async fn list_access_info(
&self,
_request: Request<()>,
) -> Result<Response<ListAccessInfoResponse>, Status> {
todo!()
}

Expand Down

0 comments on commit 08b154e

Please sign in to comment.