Fix repository advanced filtering on time column [SCI-6467] (#3805)

This commit is contained in:
Alex Kriuchykhin 2022-01-31 09:41:20 +01:00 committed by GitHub
parent c8784d1f66
commit fbcb94193a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View file

@ -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!'

View file

@ -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),