Adição de debug no processamento de cada avaliação.
This commit is contained in:
@@ -20,14 +20,14 @@ struct CsvHeader {
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
struct CsvEvaluation {
|
||||
APRESENTAÇÃO: u8,
|
||||
CONFIRMAÇÃO_DE_EMAIL: u8,
|
||||
CONFIRMAÇÃO_DE_TELEFONE: u8,
|
||||
APRESENTACAO: u8,
|
||||
CONFIRMACAO_DE_EMAIL: u8,
|
||||
CONFIRMACAO_DE_TELEFONE: u8,
|
||||
PROTOCOLO: u8,
|
||||
USO_DO_PORTUGUÊS: u8,
|
||||
PACIÊNCIA_E_EDUCAÇÃO: u8,
|
||||
USO_DO_PORTUGUES: u8,
|
||||
PACIENCIA_E_EDUCACAO: u8,
|
||||
DISPONIBILIDADE: u8,
|
||||
CONHECIMENTO_TÉCNICO: u8,
|
||||
CONHECIMENTO_TECNICO: u8,
|
||||
DIDATISMO: u8,
|
||||
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()
|
||||
.has_headers(true)
|
||||
.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
|
||||
.filter_ok(|value| value.PONTOS.is_some())
|
||||
.map_ok(|value| {
|
||||
let col =
|
||||
Column::new(value.CATEGORIA.into(), [value.PONTOS.unwrap() as u32]);
|
||||
col
|
||||
})
|
||||
.filter_map(|value| {
|
||||
if value.is_ok() {
|
||||
return Some(value.unwrap());
|
||||
// ---------- LOG 2: tenta desserializar e conta os registros ----------
|
||||
let deserialized = reader.deserialize::<CsvHeader>().collect::<Vec<_>>();
|
||||
eprintln!("🧾 Total de linhas lidas (incluindo cabeçalho): {}", deserialized.len());
|
||||
|
||||
for (i, result) in deserialized.iter().enumerate() {
|
||||
match result {
|
||||
Ok(record) => {
|
||||
eprintln!("✅ Linha {}: CATEGORIA={}, PONTOS={:?}", i, record.CATEGORIA, record.PONTOS);
|
||||
}
|
||||
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();
|
||||
|
||||
if columns.len() != 9 {
|
||||
@@ -265,7 +285,7 @@ fn main() {
|
||||
// filename example is: CC - Erraoander Quintana - 515578 - 20251020515578.csv
|
||||
// id talk is the last information, so in the example is: 20251020515578
|
||||
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
|
||||
.file_name()
|
||||
@@ -276,10 +296,10 @@ fn main() {
|
||||
.expect("Failed to do regex capture");
|
||||
|
||||
let user_name = found_regex_groups_in_filename
|
||||
.get(2)
|
||||
.get(1)
|
||||
.expect("Failed to get the id from regex maches");
|
||||
let talk_id = found_regex_groups_in_filename
|
||||
.get(5)
|
||||
.get(3)
|
||||
.expect("Failed to get the id from regex maches");
|
||||
|
||||
let excelence_percentual = columns
|
||||
@@ -494,10 +514,10 @@ fn main() {
|
||||
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>, Nícolas Borges da Silva <nicolas.borges@nova.net.br> ";
|
||||
println!("Trying to send mail... {recipients}");
|
||||
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_PASSWORD,
|
||||
recipients,
|
||||
|
||||
Reference in New Issue
Block a user