From 284813c655fb6de6cc675d2d07bda2dc4edd4803 Mon Sep 17 00:00:00 2001 From: Andrej Date: Wed, 15 May 2024 15:29:00 +0200 Subject: [PATCH] Fix date filtering for global search [SCI-10710] --- app/controllers/search_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index d4d5289c9..11450163c 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -232,11 +232,11 @@ class SearchController < ApplicationController if @filters[attribute][:on].present? from_date = Time.zone.parse(@filters[attribute][:on]).beginning_of_day.utc to_date = Time.zone.parse(@filters[attribute][:on]).end_of_day.utc - elsif @filters[attribute][:from].present? && @filters[attribute][:to].present? - from_date = Time.zone.parse(@filters[attribute][:from]) - to_date = Time.zone.parse(@filters[attribute][:to]) end + from_date = Time.zone.parse(@filters[attribute][:from]) if @filters[attribute][:from].present? + to_date = Time.zone.parse(@filters[attribute][:to]) if @filters[attribute][:to].present? + @records = @records.where("#{model_name}.#{attribute} >= ?", from_date) if from_date.present? @records = @records.where("#{model_name}.#{attribute} <= ?", to_date) if to_date.present? end