add support for __gte, __gt, __lte, and _lt for acqlia searches (perl)
authorGalen Charlton <gmc@equinoxinitiative.org>
Thu, 13 Feb 2020 17:14:52 +0000 (12:14 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 13 Feb 2020 17:15:23 +0000 (12:15 -0500)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm

index 8619f6f..2954c48 100644 (file)
@@ -79,7 +79,7 @@ sub prepare_acqlia_search_and {
         };
 
         # castdate not supported for acqlia fields: they're all type text
-        my ($k, $v, $fuzzy, $between, $not, $starts, $ends) = breakdown_term($unit);
+        my ($k, $v, $fuzzy, $between, $not, $starts, $ends, $castdate, $gte, $lte, $age, $gt, $lt) = breakdown_term($unit);
         my $point = $subquery->{"where"}->{"-and"};
         my $term_clause;
 
@@ -91,6 +91,14 @@ sub prepare_acqlia_search_and {
             push @$point, {"attr_value" => {"ilike" => $v . "%"}};
         } elsif ($ends and not ref $v) {
             push @$point, {"attr_value" => {"ilike" => "%" . $v}};
+        } elsif ($gte and not ref $v) {
+            push @$point, {"attr_value" => {">=" => $v}};
+        } elsif ($lte and not ref $v) {
+            push @$point, {"attr_value" => {"<=" => $v}};
+        } elsif ($gt and not ref $v) {
+            push @$point, {"attr_value" => {">" => $v}};
+        } elsif ($lt and not ref $v) {
+            push @$point, {"attr_value" => {"<" => $v}};
         } elsif ($between and could_be_range($v)) {
             push @$point, {"attr_value" => {"between" => $v}};
         } elsif (check_1d_max($v)) {
@@ -113,7 +121,7 @@ sub prepare_acqlia_search_or {
 
     foreach my $unit (@$acqlia) {
         # castdate not supported for acqlia fields: they're all type text
-        my ($k, $v, $fuzzy, $between, $not, $starts, $ends) = breakdown_term($unit);
+        my ($k, $v, $fuzzy, $between, $not, $starts, $ends, $castdate, $gte, $lte, $age, $gt, $lt) = breakdown_term($unit);
         my $term_clause;
         if ($fuzzy and not ref $v) {
             $term_clause = {
@@ -136,6 +144,34 @@ sub prepare_acqlia_search_or {
                     "attr_value" => {"ilike" => "%" . $v}
                 }
             };
+        } elsif ($gte and not ref $v) {
+            $term_clause = {
+                "-and" => {
+                    "definition" => $k,
+                    "attr_value" => {">=" => $v}
+                }
+            };
+        } elsif ($lte and not ref $v) {
+            $term_clause = {
+                "-and" => {
+                    "definition" => $k,
+                    "attr_value" => {"<=" => $v}
+                }
+            };
+        } elsif ($gt and not ref $v) {
+            $term_clause = {
+                "-and" => {
+                    "definition" => $k,
+                    "attr_value" => {">" => $v}
+                }
+            };
+        } elsif ($lt and not ref $v) {
+            $term_clause = {
+                "-and" => {
+                    "definition" => $k,
+                    "attr_value" => {">" => $v}
+                }
+            };
         } elsif ($between and could_be_range($v)) {
             $term_clause = {
                 "-and" => {