From 811f60fa0e4dd68e2f323f9788f03037f33243f1 Mon Sep 17 00:00:00 2001 From: Araozu Date: Thu, 16 Nov 2023 12:24:57 -0500 Subject: [PATCH] [BE][Scans] Fix UI error with certs with only DNI. Add unix timestamp to the names of the PDF generated --- backend/src/controller/scans/mod.rs | 18 ++++++++++++++---- backend/src/model/register.rs | 2 +- frontend/src/Scans/index.tsx | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/src/controller/scans/mod.rs b/backend/src/controller/scans/mod.rs index 633129b..859d9ed 100644 --- a/backend/src/controller/scans/mod.rs +++ b/backend/src/controller/scans/mod.rs @@ -142,8 +142,7 @@ fn get_details_from_paths(paths: Vec) -> Vec<(PathBuf, ScanInfo)> { fn get_image_info(path: PathBuf) -> ScanInfo { let img = image::open(&path).unwrap(); - // get unix timestamp now - // Get current time in seconds + // get unix timestamp now in ms let current_time = SystemTime::now().duration_since(UNIX_EPOCH); let current_time = match current_time { Ok(t) => t, @@ -250,7 +249,7 @@ async fn convert_scans_from_data(data: &Vec<(PathBuf, ScanInfo)>) -> Result<(), ); let register_id_list = ids.join(","); - let person_dni_list = dnis.join("-"); + let person_dni_list = dnis.join(","); log::info!("register_id_list: {}", register_id_list); log::info!("person_dni_list: {}", person_dni_list); @@ -298,12 +297,23 @@ async fn convert_scans_from_data(data: &Vec<(PathBuf, ScanInfo)>) -> Result<(), } }; + let current_time = SystemTime::now().duration_since(UNIX_EPOCH); + let current_time = match current_time { + Ok(t) => t, + Err(err) => { + log::error!("Error obteniendo hora actual: {:?}", err); + continue; + } + }; + let current_ms = current_time.as_millis(); + let filename = format!( - "{} {} {} - {} [{:X}].pdf", + "{} {} {} - {} [{}][{:X}].pdf", person_info.person_names, person_info.person_paternal_surname, person_info.person_maternal_surname, person_info.course_name, + current_ms, person_info.register_id, ); diff --git a/backend/src/model/register.rs b/backend/src/model/register.rs index 7201293..da13a66 100644 --- a/backend/src/model/register.rs +++ b/backend/src/model/register.rs @@ -195,7 +195,7 @@ impl Register { select '' as 'course_name', 0 as register_id, - '' as person_dni, + person.person_dni, person.person_names, person.person_paternal_surname, person.person_maternal_surname diff --git a/frontend/src/Scans/index.tsx b/frontend/src/Scans/index.tsx index 9878cc7..9631e0d 100644 --- a/frontend/src/Scans/index.tsx +++ b/frontend/src/Scans/index.tsx @@ -23,7 +23,7 @@ function dataFromScanResult(result: ScanResult) { if ("Full" in result) { return `DNI: ${result.Full[0]}, iid: ${result.Full[1]}`; } else if ("Partial" in result) { - return `DNI: ${result.Partial}`; + return `DNI: ${result.Partial[0]}`; } else if ("Error" in result) { return `Error: ${result.Error}`; }