fix
This commit is contained in:
parent
6677434ca0
commit
55b318b2f1
2 changed files with 17 additions and 3 deletions
|
@ -50,8 +50,10 @@ impl Location {
|
||||||
let locations = get_locations!();
|
let locations = get_locations!();
|
||||||
for loc in locations.keys() {
|
for loc in locations.keys() {
|
||||||
let loc = locations.get(loc).unwrap();
|
let loc = locations.get(loc).unwrap();
|
||||||
if *loc.parent.as_ref().unwrap_or(&String::new()) == self.id {
|
if let Some(parent) = &loc.parent {
|
||||||
ret.push(loc.clone());
|
if *parent == self.id {
|
||||||
|
ret.push(loc.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -59,7 +59,15 @@ macro_rules! get_locations {
|
||||||
if let Some(client) = $crate::LOCATIONS.get() {
|
if let Some(client) = $crate::LOCATIONS.get() {
|
||||||
client
|
client
|
||||||
} else {
|
} else {
|
||||||
let locations = $crate::JSONStore::new("./locations");
|
let mut locations: $crate::json_store::JSONStore<$crate::location::Location> =
|
||||||
|
$crate::JSONStore::new("./locations");
|
||||||
|
|
||||||
|
let loc_keys: Vec<_> = locations.keys().cloned().collect();
|
||||||
|
for loc in loc_keys {
|
||||||
|
let location = locations.get_mut(&loc).unwrap();
|
||||||
|
location.id = loc.clone();
|
||||||
|
}
|
||||||
|
|
||||||
$crate::LOCATIONS.set(locations).unwrap();
|
$crate::LOCATIONS.set(locations).unwrap();
|
||||||
$crate::LOCATIONS.get().unwrap()
|
$crate::LOCATIONS.get().unwrap()
|
||||||
}
|
}
|
||||||
|
@ -98,6 +106,10 @@ async fn rocket() -> _ {
|
||||||
.to_cors()
|
.to_cors()
|
||||||
.expect("error creating CORS options");
|
.expect("error creating CORS options");
|
||||||
|
|
||||||
|
let pg = get_pg!();
|
||||||
|
|
||||||
|
sqlx::migrate!("./migrations").run(pg).await.unwrap();
|
||||||
|
|
||||||
let config = config::get_config();
|
let config = config::get_config();
|
||||||
let itemdb = get_itemdb!().clone();
|
let itemdb = get_itemdb!().clone();
|
||||||
let locations = get_locations!().clone();
|
let locations = get_locations!().clone();
|
||||||
|
|
Loading…
Reference in a new issue