mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-22 14:16:19 +00:00
fix(best_selling): arreglar error
This commit is contained in:
parent
150f229971
commit
d00cdc6bba
1 changed files with 7 additions and 3 deletions
|
@ -120,18 +120,22 @@ pub async fn get_all_best_selling(db: &Db) -> anyhow::Result<Vec<BestSellingReco
|
||||||
.collect::<Vec<Vec<String>>>()
|
.collect::<Vec<Vec<String>>>()
|
||||||
.map(|r| {
|
.map(|r| {
|
||||||
let ranked = rank_eans(r);
|
let ranked = rank_eans(r);
|
||||||
BestSellingRecord {
|
if ranked.is_empty() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
Some(BestSellingRecord {
|
||||||
fetched_at: Utc::now(),
|
fetched_at: Utc::now(),
|
||||||
category: category.clone(),
|
category: category.clone(),
|
||||||
eans: ranked,
|
eans: ranked,
|
||||||
}
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.buffer_unordered(5)
|
.buffer_unordered(5)
|
||||||
.boxed()
|
.boxed()
|
||||||
|
.filter_map(|f| async { f })
|
||||||
.collect::<Vec<BestSellingRecord>>()
|
.collect::<Vec<BestSellingRecord>>()
|
||||||
.await;
|
.await;
|
||||||
if records.len() < 10 {
|
if records.len() < Category::value_variants().len() {
|
||||||
Err(SimpleError::new("Too few BestSellingRecords").into())
|
Err(SimpleError::new("Too few BestSellingRecords").into())
|
||||||
} else {
|
} else {
|
||||||
Ok(records)
|
Ok(records)
|
||||||
|
|
Loading…
Reference in a new issue