From 3af0eab69323a187fbc418de1c6683ca8d8cd9de Mon Sep 17 00:00:00 2001 From: Jelson Rodrigues Date: Wed, 15 Oct 2025 12:10:02 -0300 Subject: [PATCH] chore: started report grouping --- Cargo.toml | 12 ++++++++- PROMPT_DATA_SANITIZATION.txt | 8 ++++++ src/groupped_repport.rs | 49 ++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 PROMPT_DATA_SANITIZATION.txt create mode 100644 src/groupped_repport.rs diff --git a/Cargo.toml b/Cargo.toml index a6f937b..9d4462d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,14 @@ name = "piperun-bot" version = "0.1.0" edition = "2024" +[[bin]] +name = "groupped_repport" +path = "src/groupped_repport.rs" + +[[bin]] +name = "piperun-bot" +path = "src/main.rs" + [dependencies] http = {version = "1.3.1"} dotenv = {version = "0.15.0"} @@ -14,4 +22,6 @@ ipaddress = {version = "0.1.3"} zip = { version = "5.1.1"} walkdir = { version = "2.5.0"} lettre = {version = "0.11.18", features = ["builder"]} -anyhow = { version = "1.0.100"} \ No newline at end of file +anyhow = { version = "1.0.100"} +polars = { version = "0.51.0" } +regex = { version = "1.12.2" } \ No newline at end of file diff --git a/PROMPT_DATA_SANITIZATION.txt b/PROMPT_DATA_SANITIZATION.txt new file mode 100644 index 0000000..4b09605 --- /dev/null +++ b/PROMPT_DATA_SANITIZATION.txt @@ -0,0 +1,8 @@ +Abaixo está a avaliação de um atendimento que foi realizado. Eu preciso que a formatação fique consistente e padronizada. +Padronize o arquivo CSV da seguinte forma, deixando apenas as colunas listadas. +Título: CATEGORIA;PONTOS +A sua resposta deve ser apenas o CSV com a formatação corrigida, nada mais deve ser incluído na sua resposta. +Se não for possível padronizar o arquivo de entrada de acordo com as instruções fornecidas a resposta deve ser vazia. +As categorias são: APRESENTAÇÃO, CONFIRMAÇÃO DE E-MAIL, CONFIRMAÇÃO DE TELEFONE, PROTOCOLO, USO DO PORTUGUÊS, PACIÊNCIA E EDUCAÇÃO, DISPONIBILIDADE, CONHECIMENTO TÉCNICO, DIDATISMO, ESCLARECIMENTO, TEMPO DE ESPERA +A coluna pontos deve ter apenas os valores 0 ou 1, se no arquivo de entrada estiver incorreto a resposta deve ser vazia. +-------------------------------- diff --git a/src/groupped_repport.rs b/src/groupped_repport.rs new file mode 100644 index 0000000..a57d110 --- /dev/null +++ b/src/groupped_repport.rs @@ -0,0 +1,49 @@ +use itertools::Itertools; +use polars::prelude::*; +use reqwest; +use walkdir; + +fn main() { + let PROMPT = std::fs::read_to_string("./PROMPT_DATA_SANITIZATION.txt").expect("Failed to read the promp for data sanitization"); + + + // Get the current day in the format YYYY-MM-DD + 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") + .filter_map_ok(|entry| { + if entry.metadata().unwrap().is_dir(){ + Some(entry.file_name()) + } + else { + None + } + }) + .filter_map_ok(|entry_string_name| { + let regex_match_date = regex::Regex::new(r"(\d{4}-\d{2}-\d{2})").expect("Failed to build regex"); + + let filename = entry_string_name.to_str().unwrap(); + let matches_find = regex_match_date.find(filename); + + match matches_find { + Some(found) => { + chrono::NaiveDateTime::parse_from_str() + return Some(String::from(found)) + }, + None => {return None;} + }; + }) + .for_each(|entry| println!("{:?}", entry)); + // std::fs::ReadDir("./evaluations").for_each(|entry| println!("{:?}", entry)); + + // 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()); + } + ) + */ +} \ No newline at end of file