update
This commit is contained in:
parent
a8dfe5f0e9
commit
37475460e2
5 changed files with 93 additions and 2 deletions
17
src/db.rs
17
src/db.rs
|
@ -43,3 +43,20 @@ impl ItemDB {
|
|||
ret
|
||||
}
|
||||
}
|
||||
|
||||
/// Get all item variants which inventory is under the minimum. Returns a Vec with the item variants id and the missing quanity to reach minimum.
|
||||
pub async fn get_items_without_min_satisfied(db: &ItemDB) -> Vec<(String, i64)> {
|
||||
let mut ret = Vec::new();
|
||||
|
||||
for item in db.items() {
|
||||
let item = db.get_item(&item).unwrap();
|
||||
for var in &item.variants {
|
||||
let res = var.1.is_below_min().await;
|
||||
if res.0 {
|
||||
ret.push((format!("{}::{}", var.1.item, var.1.variant), res.1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue