refactor: Extract func to print list of missing messages

This commit is contained in:
Paul-Christian Volkmer 2024-07-03 19:43:38 +02:00
parent 2ef4ec4c90
commit f48a96e64d

View File

@ -498,6 +498,16 @@ fn main() -> Result<(), Box<dyn Error>> {
.to_string(), .to_string(),
); );
fn print_missing_ids(missing_ids: &[&String], term: &Term) {
missing_ids.iter().sorted().for_each(|&item| {
let _ = term.write_line(&format!(
"{} ({})",
item,
to_database_id(item).unwrap_or("?".into())
));
});
}
if db_meldungen.len() != xml_meldungen.len() { if db_meldungen.len() != xml_meldungen.len() {
let _ = term.write_line( let _ = term.write_line(
&style("\nNicht übereinstimmende Anzahl an Meldungen:") &style("\nNicht übereinstimmende Anzahl an Meldungen:")
@ -522,13 +532,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.to_string(), .to_string(),
); );
missing_db_ids.iter().sorted().for_each(|&item| { print_missing_ids(&missing_db_ids, &term);
let _ = term.write_line(&format!(
"{} ({})",
item,
to_database_id(item).unwrap_or("?".into())
));
});
} }
if !missing_xml_ids.is_empty() { if !missing_xml_ids.is_empty() {
@ -538,13 +542,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.to_string(), .to_string(),
); );
missing_xml_ids.iter().sorted().for_each(|&item| { print_missing_ids(&missing_xml_ids, &term);
let _ = term.write_line(&format!(
"{} ({})",
item,
to_database_id(item).unwrap_or("?".into())
));
});
} }
} }