From d00cdc6bbaa21071a85523a5a793afebcc28e5f6 Mon Sep 17 00:00:00 2001 From: Nulo Date: Sun, 23 Jun 2024 14:02:51 -0300 Subject: [PATCH] fix(best_selling): arreglar error --- scraper-rs/src/best_selling.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scraper-rs/src/best_selling.rs b/scraper-rs/src/best_selling.rs index 420d087..d844eb1 100644 --- a/scraper-rs/src/best_selling.rs +++ b/scraper-rs/src/best_selling.rs @@ -120,18 +120,22 @@ pub async fn get_all_best_selling(db: &Db) -> anyhow::Result>>() .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::>() .await; - if records.len() < 10 { + if records.len() < Category::value_variants().len() { Err(SimpleError::new("Too few BestSellingRecords").into()) } else { Ok(records)