refactor
This commit is contained in:
parent
02966c0605
commit
fb6a96ff55
6 changed files with 15 additions and 37 deletions
|
@ -1,6 +1,6 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use mongod::{vec_to_api, ToAPI};
|
||||
use mongod::ToAPI;
|
||||
use rocket::{get, State};
|
||||
use serde_json::json;
|
||||
|
||||
|
@ -9,9 +9,7 @@ use crate::{
|
|||
config::Config,
|
||||
flow::FlowInfo,
|
||||
json_store::JSONStore,
|
||||
location::Location,
|
||||
routes::{api_error, FallibleApiResponse, Token},
|
||||
transaction::Transaction,
|
||||
};
|
||||
|
||||
#[get("/flow/<id>/info")]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{collections::HashMap, ops::Deref};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use mongod::{vec_to_api, ToAPI};
|
||||
use rocket::{get, State};
|
||||
|
@ -42,7 +42,7 @@ async fn location_api_resolve(
|
|||
if parent == id {
|
||||
sub_l.insert(
|
||||
sub_loc.0.clone(),
|
||||
Box::pin(location_api_resolve(&sub_loc.0, &sub_loc.1, locations)).await,
|
||||
Box::pin(location_api_resolve(sub_loc.0, sub_loc.1, locations)).await,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ async fn location_api_resolve(
|
|||
.as_object_mut()
|
||||
.unwrap()
|
||||
.insert("sub".to_string(), serde_json::to_value(sub_l).unwrap());
|
||||
return loc_api;
|
||||
loc_api
|
||||
}
|
||||
|
||||
#[get("/locations")]
|
||||
|
@ -82,7 +82,7 @@ pub async fn locations_info(
|
|||
|
||||
let mut root_locations = HashMap::new();
|
||||
|
||||
for loc in locations.inner().deref() {
|
||||
for loc in &**locations.inner() {
|
||||
if loc.1.parent.is_none() {
|
||||
root_locations.insert(loc.0, loc.1);
|
||||
}
|
||||
|
@ -109,15 +109,10 @@ pub async fn location_inventory(
|
|||
) -> FallibleApiResponse {
|
||||
check_auth!(t, c);
|
||||
|
||||
if let Some(rec) = recursive {
|
||||
match rec {
|
||||
"true" | "yes" | "1" => {
|
||||
return Ok(json!(
|
||||
vec_to_api(&Transaction::in_location_recursive(location).await).await
|
||||
));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if let Some("true" | "yes" | "1") = recursive {
|
||||
return Ok(json!(
|
||||
vec_to_api(&Transaction::in_location_recursive(location).await).await
|
||||
));
|
||||
}
|
||||
|
||||
Ok(json!(
|
||||
|
|
|
@ -127,7 +127,7 @@ pub async fn min_items_route(
|
|||
) -> FallibleApiResponse {
|
||||
check_auth!(t, c);
|
||||
|
||||
let t: Vec<_> = get_items_without_min_satisfied(&itemdb)
|
||||
let t: Vec<_> = get_items_without_min_satisfied(itemdb)
|
||||
.await
|
||||
.into_iter()
|
||||
.map(|x| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue