chore: calculate excelence percentual for chats

This commit is contained in:
2025-11-05 10:32:47 -03:00
parent 1ba0510a3e
commit ca227ee45f
3 changed files with 87 additions and 71 deletions

View File

@@ -262,6 +262,17 @@ fn main() {
.get(5) .get(5)
.expect("Failed to get the id from regex maches"); .expect("Failed to get the id from regex maches");
let excelence_percentual = columns
.iter()
.map(|col| col.as_materialized_series().u32().unwrap().sum().unwrap())
.sum::<u32>() as f32
/ columns.iter().len() as f32
* 100.0;
columns.push(Column::new(
"PERCENTUAL DE EXELENCIA".into(),
[format!("{excelence_percentual:.2}")],
));
columns.push(Column::new("ID_TALK".into(), [talk_id.clone().as_str()])); columns.push(Column::new("ID_TALK".into(), [talk_id.clone().as_str()]));
let df = polars::frame::DataFrame::new(columns) let df = polars::frame::DataFrame::new(columns)
@@ -369,13 +380,13 @@ fn main() {
let recipients = "Wilson da Conceição Oliveira <wilson.oliveira@nova.net.br>, Isadora G. Moura de Moura <isadora.moura@nova.net.br>"; let recipients = "Wilson da Conceição Oliveira <wilson.oliveira@nova.net.br>, Isadora G. Moura de Moura <isadora.moura@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!( // &format!(
"Relatório agrupado dos atendimentos semana {first_day_of_last_week} - {last_day_of_last_week}" // "Relatório agrupado dos atendimentos semana {first_day_of_last_week} - {last_day_of_last_week}"
), // ),
&BOT_EMAIL, // &BOT_EMAIL,
&BOT_EMAIL_PASSWORD, // &BOT_EMAIL_PASSWORD,
recipients, // recipients,
&format!("./groupped/{first_day_of_last_week} - {last_day_of_last_week}.zip"), // &format!("./groupped/{first_day_of_last_week} - {last_day_of_last_week}.zip"),
); // );
} }

View File

@@ -10,8 +10,8 @@ use serde_json::{self, json};
use std::io::prelude::*; use std::io::prelude::*;
pub mod zip_directory_util;
pub mod send_mail_util; pub mod send_mail_util;
pub mod zip_directory_util;
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {
match dotenv::dotenv().ok() { match dotenv::dotenv().ok() {
@@ -529,7 +529,13 @@ fn main() -> anyhow::Result<()> {
let recipients = "Wilson da Conceição Oliveira <wilson.oliveira@nova.net.br>, Isadora G. Moura de Moura <isadora.moura@nova.net.br>"; let recipients = "Wilson da Conceição Oliveira <wilson.oliveira@nova.net.br>, Isadora G. Moura de Moura <isadora.moura@nova.net.br>";
println!("Trying to send email... Recipients {recipients}"); println!("Trying to send email... Recipients {recipients}");
send_mail_util::send_mail_util::send_email(&format!("Avaliacao atendimentos {formatted_day_before}"), &BOT_EMAIL, &BOT_EMAIL_PASSWORD, recipients, &output_zip_file_str); send_mail_util::send_mail_util::send_email(
&format!("Avaliacao atendimentos {formatted_day_before}"),
&BOT_EMAIL,
&BOT_EMAIL_PASSWORD,
recipients,
&output_zip_file_str,
);
return Ok(()); return Ok(());
} }

View File

@@ -66,5 +66,4 @@ pub fn zip_source_dir_to_dst_file(src_dir: &Path, dst_file: &Path) {
zip_dir(&mut it.filter_map(|e| e.ok()), src_dir, file, method); zip_dir(&mut it.filter_map(|e| e.ok()), src_dir, file, method);
} }
} }