fix(best_selling): arreglar error

This commit is contained in:
Cat /dev/Nulo 2024-06-23 14:02:51 -03:00
parent 150f229971
commit d00cdc6bba

View file

@ -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)