From 867a1e871d1a162ccd8d0eaa72f352748aa8abe4 Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Tue, 2 Jul 2013 11:19:05 -0400 Subject: [PATCH] Rearrange some logic in get_combined_holdings() The logic in get_combined_holdings() was a little sloppy and repeated some steps unnecessarily. This cleans things up. Signed-off-by: Dan Wells --- Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD.pm | 27 +++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD.pm index 82a02bef13..03975cf176 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD.pm @@ -550,12 +550,20 @@ sub get_combined_holdings { $combined_holdings[-1]->clone->compressed_to_last : $combined_holdings[-1]->clone; + # next, get the end (or only) holding of the current + # holding being considered + my $holding_end; + if ($holding->is_compressed) { + $holding_end = $holding->is_open_ended ? + undef + : $holding->clone->compressed_to_last; + } else { + $holding_end = $holding; + } + # next, make sure $holding isn't fully contained - my $holding_end = $holding->is_compressed ? - $holding->clone->compressed_to_last - : $holding; - # if $holding is fully contained, skip it - if ($holding_end le $last_holding_end) { + # if it is, skip it + if ($holding_end and $holding_end le $last_holding_end) { next; } @@ -564,16 +572,9 @@ sub get_combined_holdings { $holding->clone->compressed_to_first : $holding; + # see if they overlap if ($last_holding_end->increment ge $holding_start) { # they overlap, combine them - my $holding_end; - if ($holding->is_compressed) { - $holding_end = $holding->is_open_ended ? - undef - : $holding->compressed_to_last; - } else { - $holding_end = $holding; - } $combined_holdings[-1]->compressed_end($holding_end); } else { # no overlap, start a new group -- 2.11.0