Ignorar chats que iniciam com template + response_time semana e mensal + novo prompt + novo filter #2

Open
nicolas.borges wants to merge 19 commits from nicolas.borges/sup_piperun-bot:main into main
Showing only changes of commit 2d5206ebd9 - Show all commits

View File

@@ -20,14 +20,14 @@ struct CsvHeader {
#[derive(Debug, serde::Deserialize)] #[derive(Debug, serde::Deserialize)]
struct CsvEvaluation { struct CsvEvaluation {
APRESENTAÇÃO: u8, APRESENTACAO: u8,
CONFIRMAÇÃO_DE_EMAIL: u8, CONFIRMACAO_DE_EMAIL: u8,
CONFIRMAÇÃO_DE_TELEFONE: u8, CONFIRMACAO_DE_TELEFONE: u8,
PROTOCOLO: u8, PROTOCOLO: u8,
USO_DO_PORTUGUÊS: u8, USO_DO_PORTUGUES: u8,
PACIÊNCIA_E_EDUCAÇÃO: u8, PACIENCIA_E_EDUCACAO: u8,
DISPONIBILIDADE: u8, DISPONIBILIDADE: u8,
CONHECIMENTO_TÉCNICO: u8, CONHECIMENTO_TECNICO: u8,
DIDATISMO: u8, DIDATISMO: u8,
ID_TALK: String, ID_TALK: String,
} }
@@ -234,27 +234,47 @@ fn main() {
} }
}; };
}) })
.filter_map_ok(|(ai_repsonse, file_path_csv)| { .filter_map_ok(|(ai_response, file_path_csv)| {
// ---------- LOG 1: mostra qual arquivo está sendo processado ----------
eprintln!("🔍 Processando arquivo: {:?}", file_path_csv);
// Opcional: mostrar as primeiras linhas do CSV
eprintln!("📄 Primeiras 200 caracteres do CSV:\n{}", &ai_response[..200.min(ai_response.len())]);
//
let mut reader = csv::ReaderBuilder::new() let mut reader = csv::ReaderBuilder::new()
.has_headers(true) .has_headers(true)
.delimiter(b';') .delimiter(b';')
.from_reader(ai_repsonse.as_bytes()); .from_reader(ai_response.as_bytes());
let mut deserialized_iter = reader.deserialize::<CsvHeader>();
let mut columns = deserialized_iter // ---------- LOG 2: tenta desserializar e conta os registros ----------
.filter_ok(|value| value.PONTOS.is_some()) let deserialized = reader.deserialize::<CsvHeader>().collect::<Vec<_>>();
.map_ok(|value| { eprintln!("🧾 Total de linhas lidas (incluindo cabeçalho): {}", deserialized.len());
let col =
Column::new(value.CATEGORIA.into(), [value.PONTOS.unwrap() as u32]); for (i, result) in deserialized.iter().enumerate() {
col match result {
}) Ok(record) => {
.filter_map(|value| { eprintln!("✅ Linha {}: CATEGORIA={}, PONTOS={:?}", i, record.CATEGORIA, record.PONTOS);
if value.is_ok() {
return Some(value.unwrap());
} }
None Err(e) => {
eprintln!("❌ Linha {} ERRO: {}", i, e);
}
}
}
let mut columns = deserialized
.into_iter() // usa os registros já lidos
.filter_ok(|value| {
// Se PONTOS for None, considera como 0 e mantém a linha
true // sempre mantém
}) })
.map_ok(|value| {
let pontos = value.PONTOS.unwrap_or(0) as u32;
Column::new(value.CATEGORIA.into(), [pontos])
})
.filter_map(|value| value.ok())
.collect_vec(); .collect_vec();
if columns.len() != 9 { if columns.len() != 9 {
@@ -265,7 +285,7 @@ fn main() {
// filename example is: CC - Erraoander Quintana - 515578 - 20251020515578.csv // filename example is: CC - Erraoander Quintana - 515578 - 20251020515578.csv
// id talk is the last information, so in the example is: 20251020515578 // id talk is the last information, so in the example is: 20251020515578
let regex_filename = let regex_filename =
regex::Regex::new(r"(CC - |ATEND - )((\w+\s*)+) - (\d+) - (\d+).csv").unwrap(); regex::Regex::new(r"ATEND - (.+?) - (\d+) - (\d+)\.csv").unwrap();
let filename = file_path_csv let filename = file_path_csv
.file_name() .file_name()
@@ -276,10 +296,10 @@ fn main() {
.expect("Failed to do regex capture"); .expect("Failed to do regex capture");
let user_name = found_regex_groups_in_filename let user_name = found_regex_groups_in_filename
.get(2) .get(1)
.expect("Failed to get the id from regex maches"); .expect("Failed to get the id from regex maches");
let talk_id = found_regex_groups_in_filename let talk_id = found_regex_groups_in_filename
.get(5) .get(3)
.expect("Failed to get the id from regex maches"); .expect("Failed to get the id from regex maches");
let excelence_percentual = columns let excelence_percentual = columns
@@ -494,10 +514,10 @@ fn main() {
std::path::Path::new(&format!("./groupped/{first_day_of_last_month}.zip")), std::path::Path::new(&format!("./groupped/{first_day_of_last_month}.zip")),
); );
let recipients = "Wilson da Conceição Oliveira <wilson.oliveira@nova.net.br>, nicolas.borges@nova.net.br, Isadora G. Moura de Moura <isadora.moura@nova.net.br>"; let recipients = "Isadora G. Moura de Moura <isadora.moura@nova.net.br>, Wilson da Conceição Oliveira <wilson.oliveira@nova.net.br>, colas Borges da Silva <nicolas.borges@nova.net.br> ";
println!("Trying to send mail... {recipients}"); println!("Trying to send mail... {recipients}");
send_mail_util::send_mail_util::send_email( send_mail_util::send_mail_util::send_email(
&format!("Relatório agrupado dos atendimentos do mês {first_day_of_last_month}"), &format!("Relatório agrupado dos atendimentos da fila do Atendimento do mês {first_day_of_last_month}"),
&BOT_EMAIL, &BOT_EMAIL,
&BOT_EMAIL_PASSWORD, &BOT_EMAIL_PASSWORD,
recipients, recipients,