mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-22 06:16:18 +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>>>()
|
||||
.map(|r| {
|
||||
let ranked = rank_eans(r);
|
||||
BestSellingRecord {
|
||||
if ranked.is_empty() {
|
||||
return None;
|
||||
}
|
||||
Some(BestSellingRecord {
|
||||
fetched_at: Utc::now(),
|
||||
category: category.clone(),
|
||||
eans: ranked,
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
.buffer_unordered(5)
|
||||
.boxed()
|
||||
.filter_map(|f| async { f })
|
||||
.collect::<Vec<BestSellingRecord>>()
|
||||
.await;
|
||||
if records.len() < 10 {
|
||||
if records.len() < Category::value_variants().len() {
|
||||
Err(SimpleError::new("Too few BestSellingRecords").into())
|
||||
} else {
|
||||
Ok(records)
|
||||
|
|
Loading…
Reference in a new issue