forked from jelson.rodrigues/piperun-bot
chore: obtain previoous week dates
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
use std::fmt::Debug;
|
||||||
|
|
||||||
|
use chrono::Datelike;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use polars::prelude::*;
|
use polars::prelude::*;
|
||||||
use reqwest;
|
use reqwest;
|
||||||
@@ -11,7 +14,7 @@ fn main() {
|
|||||||
let current_date = chrono::Local::now();
|
let current_date = chrono::Local::now();
|
||||||
let formatted_date = current_date.format("%Y-%m-%d").to_string();
|
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| {
|
.filter_map_ok(|entry| {
|
||||||
if entry.metadata().unwrap().is_dir(){
|
if entry.metadata().unwrap().is_dir(){
|
||||||
Some(entry.file_name())
|
Some(entry.file_name())
|
||||||
@@ -28,22 +31,48 @@ fn main() {
|
|||||||
|
|
||||||
match matches_find {
|
match matches_find {
|
||||||
Some(found) => {
|
Some(found) => {
|
||||||
chrono::NaiveDateTime::parse_from_str()
|
let date = chrono::NaiveDate::parse_from_str(found.as_str(), "%Y-%m-%d");
|
||||||
return Some(String::from(found))
|
return Some((date.unwrap().week(chrono::Weekday::Sun), entry_string_name));
|
||||||
},
|
},
|
||||||
None => {return None;}
|
None => {return None;}
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.for_each(|entry| println!("{:?}", entry));
|
.filter_map_ok(|(week, directory_string)| {
|
||||||
// std::fs::ReadDir("./evaluations").for_each(|entry| println!("{:?}", entry));
|
let current_date = chrono::Local::now();
|
||||||
|
let first_day_of_current_week = current_date.date_naive().week(chrono::Weekday::Sun).first_day();
|
||||||
// get folder name for last week evaluations
|
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 evaluations_dir_walk = walkdir::WalkDir::new("./evaluations");
|
let first_day_of_week_in_folder_name = week.first_day();
|
||||||
evaluations_dir_walk.into_iter().for_each(
|
|
||||||
|entry| {
|
if first_day_of_last_week == first_day_of_week_in_folder_name {
|
||||||
println!("{:?}", entry.unwrap());
|
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
|
||||||
|
...
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user