mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-25 19:16:19 +00:00
usar 50 coroutinas en coto
This commit is contained in:
parent
5943d80252
commit
adf1d7ac59
2 changed files with 13 additions and 6 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
use std::env;
|
||||||
|
|
||||||
use super::now_sec;
|
use super::now_sec;
|
||||||
use super::AutoArgs;
|
use super::AutoArgs;
|
||||||
use super::AutoTelegram;
|
use super::AutoTelegram;
|
||||||
|
@ -61,7 +63,16 @@ impl Auto {
|
||||||
// }
|
// }
|
||||||
{
|
{
|
||||||
let t0 = now_sec();
|
let t0 = now_sec();
|
||||||
let counters = self.scraper.fetch_list(&self.db, links).await;
|
|
||||||
|
let n_coroutines = if supermercado == Supermercado::Coto {
|
||||||
|
50
|
||||||
|
} else {
|
||||||
|
env::var("N_COROUTINES")
|
||||||
|
.map_or(Ok(24), |s| s.parse::<usize>())
|
||||||
|
.expect("N_COROUTINES no es un número")
|
||||||
|
};
|
||||||
|
|
||||||
|
let counters = self.scraper.fetch_list(&self.db, links, n_coroutines).await;
|
||||||
self.inform(&format!(
|
self.inform(&format!(
|
||||||
"Downloaded {:?}: {:?} (took {})",
|
"Downloaded {:?}: {:?} (took {})",
|
||||||
&supermercado,
|
&supermercado,
|
||||||
|
|
|
@ -128,11 +128,7 @@ impl Scraper {
|
||||||
counters
|
counters
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn fetch_list(&self, db: &Db, links: Vec<String>) -> Counters {
|
pub async fn fetch_list(&self, db: &Db, links: Vec<String>, n_coroutines: usize) -> Counters {
|
||||||
let n_coroutines = env::var("N_COROUTINES")
|
|
||||||
.map_or(Ok(24), |s| s.parse::<usize>())
|
|
||||||
.expect("N_COROUTINES no es un número");
|
|
||||||
|
|
||||||
stream::iter(links)
|
stream::iter(links)
|
||||||
.map(|url| {
|
.map(|url| {
|
||||||
let db = db.clone();
|
let db = db.clone();
|
||||||
|
|
Loading…
Reference in a new issue