web: use new utility function in callback

This commit is contained in:
Emilia Allison 2024-02-13 19:58:14 -05:00
parent 6c8533f7a6
commit 1aa4c1b7bb
Signed by: emilia
GPG Key ID: 05D5D1107E5100A1
1 changed files with 3 additions and 17 deletions

View File

@ -16,7 +16,7 @@ use plate_tool_lib::util::letters_to_num;
use plate_tool_lib::transfer::Transfer; use plate_tool_lib::transfer::Transfer;
use plate_tool_lib::transfer_region::{Region, TransferRegion}; use plate_tool_lib::transfer_region::{Region, TransferRegion};
use plate_tool_lib::csv::TransferRecord; use plate_tool_lib::csv::{TransferRecord, string_well_to_pt};
use super::main_window_callbacks::create_close_button; use super::main_window_callbacks::create_close_button;
@ -229,28 +229,14 @@ pub fn import_transfer_csv_submit_callback(
let from_dest = from_dest.value(); let from_dest = from_dest.value();
let to_dest = to_dest.value(); let to_dest = to_dest.value();
lazy_static! {
static ref REGEX: Regex = Regex::new(r"([A-Z,a-z]+)(\d+)").unwrap();
}
let records: Vec<((u8, u8), (u8, u8))> = records let records: Vec<((u8, u8), (u8, u8))> = records
.iter() .iter()
.filter(|record| record.source_plate == from_source) .filter(|record| record.source_plate == from_source)
.filter(|record| record.destination_plate == from_dest) .filter(|record| record.destination_plate == from_dest)
.map(|record| { .map(|record| {
let c1 = REGEX.captures(&record.source_well).unwrap();
let c2 = REGEX.captures(&record.destination_well).unwrap();
log::debug!("{} {}", &record.source_well, &record.destination_well);
log::debug!("{},{} {},{}", &c1[1], &c1[2], &c2[1], &c2[2]);
( (
( string_well_to_pt(&record.source_well).unwrap(),
letters_to_num(&c1[1]).unwrap(), string_well_to_pt(&record.destination_well).unwrap()
c1[2].parse::<u8>().unwrap(),
),
(
letters_to_num(&c2[1]).unwrap(),
c2[2].parse::<u8>().unwrap(),
),
) )
}) })
.collect(); .collect();