mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-25 19:16:19 +00:00
error when error in best selling
This commit is contained in:
parent
d00cdc6bba
commit
d495acfc9d
2 changed files with 23 additions and 7 deletions
|
@ -2,6 +2,7 @@ use super::now_sec;
|
|||
use super::supermercado::Supermercado;
|
||||
use super::AutoArgs;
|
||||
use super::AutoTelegram;
|
||||
use crate::best_selling;
|
||||
use crate::db::Db;
|
||||
use crate::scraper::Scraper;
|
||||
use futures::Future;
|
||||
|
@ -70,6 +71,27 @@ impl Auto {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn download_best_selling(&self) -> anyhow::Result<()> {
|
||||
// let best_selling: Vec<best_selling::BestSellingRecord> =
|
||||
|
||||
match self
|
||||
.inform_time(
|
||||
"Downloaded best selling",
|
||||
best_selling::get_all_best_selling(&self.db),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(best_selling) => {
|
||||
self.db.save_best_selling(best_selling).await?;
|
||||
}
|
||||
Err(err) => {
|
||||
self.inform(&format!("FAILED best selling: {:?}", err))
|
||||
.await
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn inform_time<T: Future<Output = R>, R>(&self, msg: &str, action: T) -> R {
|
||||
let t0 = now_sec();
|
||||
let res = action.await;
|
||||
|
|
|
@ -256,13 +256,7 @@ async fn auto_cli(args: AutoArgs) -> anyhow::Result<()> {
|
|||
future::try_join_all(handles).await?;
|
||||
auto.inform("[auto] Download supermercados finished").await;
|
||||
|
||||
let best_selling = auto
|
||||
.inform_time(
|
||||
"Downloaded best selling",
|
||||
best_selling::get_all_best_selling(&auto.db),
|
||||
)
|
||||
.await?;
|
||||
auto.db.save_best_selling(best_selling).await?;
|
||||
auto.download_best_selling().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue