Compare commits

...

2 commits

Author SHA1 Message Date
Nulo
ad306364b7
Merge c53897891b into 28662978ae 2024-02-06 16:26:43 +00:00
c53897891b save debug path with date 2024-02-06 13:20:56 -03:00
2 changed files with 4 additions and 2 deletions

2
.gitignore vendored
View file

@ -16,4 +16,4 @@ target/
*/flamegraph.svg */flamegraph.svg
*/perf.data* */perf.data*
scraper-rs/debug/ scraper-rs/debug*/

View file

@ -1,4 +1,5 @@
use again::RetryPolicy; use again::RetryPolicy;
use chrono::{DateTime, Utc};
use clap::{Parser, ValueEnum}; use clap::{Parser, ValueEnum};
use cron::Schedule; use cron::Schedule;
use db::Db; use db::Db;
@ -202,7 +203,8 @@ async fn fetch_and_parse(
let point = match maybe_point { let point = match maybe_point {
Ok(p) => Ok(p), Ok(p) => Ok(p),
Err(err) => { Err(err) => {
let debug_path = PathBuf::from("debug/"); let now: DateTime<Utc> = Utc::now();
let debug_path = PathBuf::from(format!("debug-{}/", now.format("%Y-%m-%d")));
tokio::fs::create_dir_all(&debug_path).await.unwrap(); tokio::fs::create_dir_all(&debug_path).await.unwrap();
let file_path = debug_path.join(format!("{}.html", nanoid!())); let file_path = debug_path.join(format!("{}.html", nanoid!()));
tokio::fs::write(&file_path, &body).await.unwrap(); tokio::fs::write(&file_path, &body).await.unwrap();