From fbcb94193a9dfff904d031759d02752525f75c90 Mon Sep 17 00:00:00 2001 From: Alex Kriuchykhin Date: Mon, 31 Jan 2022 09:41:20 +0100 Subject: [PATCH] Fix repository advanced filtering on time column [SCI-6467] (#3805) --- app/models/repository_time_value.rb | 14 +++++++------- app/services/repository_datatable_service.rb | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/models/repository_time_value.rb b/app/models/repository_time_value.rb index bb020f1e6..58ffa2bcd 100644 --- a/app/models/repository_time_value.rb +++ b/app/models/repository_time_value.rb @@ -14,19 +14,19 @@ class RepositoryTimeValue < RepositoryDateTimeValueBase parameters = filter_element.parameters case filter_element.operator when 'equal_to' - repository_rows.where(repository_date_time_values: { data: parameters['time'] }) + repository_rows.where('repository_date_time_values.data::time = ?', parameters['time']) when 'unequal_to' - repository_rows.where.not(repository_date_time_values: { data: parameters['time'] }) + repository_rows.where.not('repository_date_time_values.data::time = ?', parameters['time']) when 'greater_than' - repository_rows.where('repository_date_time_values.data > ?', parameters['time']) + repository_rows.where('repository_date_time_values.data::time > ?', parameters['time']) when 'greater_than_or_equal_to' - repository_rows.where('repository_date_time_values.data >= ?', parameters['time']) + repository_rows.where('repository_date_time_values.data::time >= ?', parameters['time']) when 'less_than' - repository_rows.where('repository_date_time_values.data < ?', parameters['time']) + repository_rows.where('repository_date_time_values.data::time < ?', parameters['time']) when 'less_than_or_equal_to' - repository_rows.where('repository_date_time_values.data =< ?', parameters['time']) + repository_rows.where('repository_date_time_values.data::time <= ?', parameters['time']) when 'between' - repository_rows.where('repository_date_time_values.data > ? AND repository_date_time_values.data < ?', + repository_rows.where('repository_date_time_values.data::time > ? AND repository_date_time_values.data::time < ?', parameters['start_time'], parameters['end_time']) else raise ArgumentError, 'Wrong operator for RepositoryTimeValue!' diff --git a/app/services/repository_datatable_service.rb b/app/services/repository_datatable_service.rb index ee8b3b7d1..97b0797bb 100644 --- a/app/services/repository_datatable_service.rb +++ b/app/services/repository_datatable_service.rb @@ -204,7 +204,7 @@ class RepositoryDatatableService when 'less_than' repository_rows.where('created_at < ?', filter_element_params.dig(:parameters, :datetime)) when 'less_than_or_equal_to' - repository_rows.where('created_at =< ?', filter_element_params.dig(:parameters, :datetime)) + repository_rows.where('created_at <= ?', filter_element_params.dig(:parameters, :datetime)) when 'between' repository_rows.where('created_at > ? AND created_at < ?', filter_element_params.dig(:parameters, :start_datetime),