From 509d05c30969e396498ee8a8d1501c923c0e6fb8 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 7 Feb 2020 10:05:54 -0500 Subject: [PATCH] add _gt/_lt operators to unified search method Signed-off-by: Galen Charlton --- Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm index 83d23a8bed..c16a5d38f4 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm @@ -52,11 +52,13 @@ sub could_be_range { } sub castdate { - my ($value, $gte, $lte, $between) = @_; + my ($value, $gte, $lte, $between, $gt, $lt) = @_; my $op = "="; $op = ">=" if $gte; $op = "<=" if $lte; + $op = ">" if $gt; + $op = "<" if $lt; $op = "between" if $between; # avoid transforming a date if the match value is NULL. @@ -168,6 +170,8 @@ sub breakdown_term { $term->{"__gte"} ? 1 : 0, $term->{"__lte"} ? 1 : 0, $term->{"__age"} ? 1 : 0, + $term->{"__gt"} ? 1 : 0, + $term->{"__lt"} ? 1 : 0, ); } @@ -328,7 +332,7 @@ sub prepare_terms { $outer_clause->{$conj} = [] unless $outer_clause->{$conj}; foreach my $unit (@{$terms->{$class}}) { my $special_clause; - my ($k, $v, $fuzzy, $between, $not, $starts, $ends, $castdate, $gte, $lte, $age) = + my ($k, $v, $fuzzy, $between, $not, $starts, $ends, $castdate, $gte, $lte, $age, $gt, $lt) = breakdown_term($unit); my $term_clause; @@ -360,10 +364,13 @@ sub prepare_terms { } } elsif (check_1d_max($v)) { if ($castdate) { - $v = castdate($v, $gte, $lte); + $v = castdate($v, $gte, $lte, 0, $gt, $lt); } elsif ($gte or $lte) { my $op = $gte ? '>=' : '<='; $v = {$op => $v}; + } elsif ($gt or $lt) { + my $op = $gt ? '>' : '<'; + $v = {$op => $v}; } elsif (not ref $v and $not) { # the old way, NOT (blah.id = $v) needs to be # (blah.id <> $x OR blah.id IS NULL) -- 2.11.0