move skip predicate into par_iter loop
This commit is contained in:
parent
fc77a1cc4b
commit
9cc7cbc7b8
33
src/main.rs
33
src/main.rs
|
@ -33,6 +33,8 @@ fn main() {
|
|||
highlight.remove(";");
|
||||
}
|
||||
|
||||
let i_skipped = std::sync::atomic::AtomicUsize::new(0);
|
||||
|
||||
let mut dat: Vec<_> = args
|
||||
.into_par_iter()
|
||||
.flat_map(|i| {
|
||||
|
@ -73,6 +75,7 @@ fn main() {
|
|||
);
|
||||
|
||||
let mut idat = Vec::new();
|
||||
let mut iisk = 0usize;
|
||||
for result in recsit {
|
||||
let record = result.expect("got invalid line");
|
||||
let record_bak = record.clone();
|
||||
|
@ -80,11 +83,22 @@ fn main() {
|
|||
std::convert::TryInto::try_into(record);
|
||||
|
||||
match pres {
|
||||
Ok(tl) => idat.push(tl),
|
||||
Ok(tl) => {
|
||||
if tl.direction == simple_enums::TransactionDirection::Haben
|
||||
&& tl.waehrung == simple_enums::Waehrung::EUR
|
||||
&& !tl.p_other.is_empty()
|
||||
&& tl.p_other.find(" ZINS BIS ").is_none()
|
||||
{
|
||||
idat.push(tl)
|
||||
} else {
|
||||
iisk += 1;
|
||||
}
|
||||
}
|
||||
Err(transaction::ParseError::Finalizer) => break,
|
||||
Err(x) => panic!("got error '{}' @ {:?}", x, record_bak),
|
||||
}
|
||||
}
|
||||
i_skipped.fetch_add(iisk, std::sync::atomic::Ordering::SeqCst);
|
||||
idat
|
||||
})
|
||||
.collect();
|
||||
|
@ -99,24 +113,11 @@ fn main() {
|
|||
(usize, transaction::TransactionValue, String, usize),
|
||||
>::new();
|
||||
|
||||
let mut i_skipped = 0usize;
|
||||
let mut newlen = 0usize;
|
||||
for i in dat.into_iter().dedup() {
|
||||
newlen += 1;
|
||||
if i.direction != simple_enums::TransactionDirection::Haben
|
||||
|| i.waehrung != simple_enums::Waehrung::EUR
|
||||
|| i.p_other.is_empty()
|
||||
|| i.p_other.find(" ZINS BIS ").is_some()
|
||||
{
|
||||
i_skipped += 1;
|
||||
continue;
|
||||
}
|
||||
let mut ent = accu
|
||||
.entry((
|
||||
i.d_buchungs.year(),
|
||||
i.d_buchungs.month() > 6,
|
||||
i.p_other.clone(),
|
||||
))
|
||||
.entry((i.d_buchungs.year(), i.d_buchungs.month() > 6, i.p_other))
|
||||
.or_default();
|
||||
ent.0 += 1;
|
||||
ent.1 += i.umsatz;
|
||||
|
@ -126,7 +127,7 @@ fn main() {
|
|||
&mut stdout,
|
||||
"skipped {} duplicates and {} misc entries",
|
||||
oldlen - newlen,
|
||||
i_skipped
|
||||
i_skipped.into_inner(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
|
Loading…
Reference in a new issue