mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 13:13:22 +08:00
Fix repository advanced filtering on time column [SCI-6467] (#3805)
This commit is contained in:
parent
c8784d1f66
commit
fbcb94193a
2 changed files with 8 additions and 8 deletions
|
@ -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!'
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue