chore: obtain previoous week dates

This commit is contained in:
2025-10-16 12:05:07 -03:00
parent 3af0eab693
commit cd44d58f69

View File

@@ -1,3 +1,6 @@
use std::fmt::Debug;
use chrono::Datelike;
use itertools::Itertools;
use polars::prelude::*;
use reqwest;
@@ -11,7 +14,7 @@ fn main() {
let current_date = chrono::Local::now();
let formatted_date = current_date.format("%Y-%m-%d").to_string();
std::fs::read_dir(std::path::Path::new("./evaluations")).expect("Failed to read directory ./evaluations")
let previous_week_folder_names = std::fs::read_dir(std::path::Path::new("./evaluations")).expect("Failed to read directory ./evaluations")
.filter_map_ok(|entry| {
if entry.metadata().unwrap().is_dir(){
Some(entry.file_name())
@@ -28,22 +31,48 @@ fn main() {
match matches_find {
Some(found) => {
chrono::NaiveDateTime::parse_from_str()
return Some(String::from(found))
let date = chrono::NaiveDate::parse_from_str(found.as_str(), "%Y-%m-%d");
return Some((date.unwrap().week(chrono::Weekday::Sun), entry_string_name));
},
None => {return None;}
};
})
.for_each(|entry| println!("{:?}", entry));
// std::fs::ReadDir("./evaluations").for_each(|entry| println!("{:?}", entry));
.filter_map_ok(|(week, directory_string)| {
let current_date = chrono::Local::now();
let first_day_of_current_week = current_date.date_naive().week(chrono::Weekday::Sun).first_day();
let current_date_minus_one_week = first_day_of_current_week.checked_sub_days(chrono::Days::new(1)).expect("Failed to subtract one day");
let first_day_of_last_week = current_date_minus_one_week.week(chrono::Weekday::Sun).first_day();
let first_day_of_week_in_folder_name = week.first_day();
// get folder name for last week evaluations
/*
let evaluations_dir_walk = walkdir::WalkDir::new("./evaluations");
evaluations_dir_walk.into_iter().for_each(
|entry| {
println!("{:?}", entry.unwrap());
if first_day_of_last_week == first_day_of_week_in_folder_name {
return Some(directory_string);
}
)
*/
return None;
})
.filter_map(|value| {
if value.is_ok() {return Some(value.unwrap());}
else {return None;}
})
.sorted()
.collect_vec();
println!("{:?}", previous_week_folder_names);
// Read CSV files inside folder
// Use AI to sanitize the data
// Save into a hashmap, with the user name as key, the date, evaluation
// Final file should look like
/*
Header: Att1, att2, att3, ...
categoria1
categoria2
categoria3
...
*/
}