From 5090b85c602f840a34ddf1a238eb55d0f40898d2 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Sat, 21 Sep 2024 02:04:09 +0200 Subject: [PATCH] item id fix --- src/db.rs | 4 ++-- src/routes/item/mod.rs | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/db.rs b/src/db.rs index 57bc915..dbc2878 100644 --- a/src/db.rs +++ b/src/db.rs @@ -30,7 +30,7 @@ impl ItemDB { .documents .iter() .map(Item::new) // <-- todo : performance? - .find(|x| x.id() == item) + .find(|x| x._id == item) } /// Get all items @@ -38,7 +38,7 @@ impl ItemDB { let mut ret = vec![]; for item in &self.index.documents { let item = Item::new(item); - ret.push(item.name); + ret.push(item._id.clone()); } ret } diff --git a/src/routes/item/mod.rs b/src/routes/item/mod.rs index f8f5ff8..1f1d582 100644 --- a/src/routes/item/mod.rs +++ b/src/routes/item/mod.rs @@ -37,7 +37,11 @@ use crate::routes::FallibleApiResponse; pub fn get_items_route(itemdb: &State, t: Token, c: &State) -> FallibleApiResponse { check_auth!(t, c); - let items = itemdb.items(); + let mut items = Vec::new(); + for item in itemdb.items() { + items.push(itemdb.get_item(&item).unwrap().api_json()); + } + Ok(json!({"items": items})) }