mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-10 17:36:33 +08:00
Apply user's time zone in advanced filters for time data type [SCI-6585] (#3930)
This commit is contained in:
parent
d777149865
commit
378fbb6b76
2 changed files with 14 additions and 14 deletions
|
@ -18,22 +18,22 @@ class RepositoryTimeRangeValue < RepositoryDateTimeRangeValueBase
|
|||
case filter_element.operator
|
||||
when 'equal_to'
|
||||
repository_rows.where("#{join_alias}.start_time::time = (?)::time AND #{join_alias}.end_time::time = (?)::time",
|
||||
parameters['start_time'], parameters['end_time'])
|
||||
Time.zone.parse(parameters['start_time']), Time.zone.parse(parameters['end_time']))
|
||||
when 'unequal_to'
|
||||
repository_rows
|
||||
.where.not("#{join_alias}.start_time::time = (?)::time AND #{join_alias}.end_time::time = (?)::time",
|
||||
parameters['start_time'], parameters['end_time'])
|
||||
Time.zone.parse(parameters['start_time']), Time.zone.parse(parameters['end_time']))
|
||||
when 'greater_than'
|
||||
repository_rows.where("#{join_alias}.start_time::time > (?)::time", parameters['end_time'])
|
||||
repository_rows.where("#{join_alias}.start_time::time > (?)::time", Time.zone.parse(parameters['end_time']))
|
||||
when 'greater_than_or_equal_to'
|
||||
repository_rows.where("#{join_alias}.start_time::time >= (?)::time", parameters['end_time'])
|
||||
repository_rows.where("#{join_alias}.start_time::time >= (?)::time", Time.zone.parse(parameters['end_time']))
|
||||
when 'less_than'
|
||||
repository_rows.where("#{join_alias}.end_time::time < (?)::time", parameters['start_time'])
|
||||
repository_rows.where("#{join_alias}.end_time::time < (?)::time", Time.zone.parse(parameters['start_time']))
|
||||
when 'less_than_or_equal_to'
|
||||
repository_rows.where("#{join_alias}.end_time::time <= (?)::time", parameters['start_time'])
|
||||
repository_rows.where("#{join_alias}.end_time::time <= (?)::time", Time.zone.parse(parameters['start_time']))
|
||||
when 'between'
|
||||
repository_rows.where("#{join_alias}.start_time::time > (?)::time AND #{join_alias}.end_time::time < (?)::time",
|
||||
parameters['start_time'], parameters['end_time'])
|
||||
Time.zone.parse(parameters['start_time']), Time.zone.parse(parameters['end_time']))
|
||||
else
|
||||
raise ArgumentError, 'Wrong operator for RepositoryTimeRangeValue!'
|
||||
end
|
||||
|
|
|
@ -14,19 +14,19 @@ class RepositoryTimeValue < RepositoryDateTimeValueBase
|
|||
parameters = filter_element.parameters
|
||||
case filter_element.operator
|
||||
when 'equal_to'
|
||||
repository_rows.where("#{join_alias}.data::time = ?", Time.zone.parse(parameters['time']))
|
||||
repository_rows.where("#{join_alias}.data::time = (?)::time", Time.zone.parse(parameters['time']))
|
||||
when 'unequal_to'
|
||||
repository_rows.where.not("#{join_alias}.data::time = ?", Time.zone.parse(parameters['time']))
|
||||
repository_rows.where.not("#{join_alias}.data::time = (?)::time", Time.zone.parse(parameters['time']))
|
||||
when 'greater_than'
|
||||
repository_rows.where("#{join_alias}.data::time > ?", Time.zone.parse(parameters['time']))
|
||||
repository_rows.where("#{join_alias}.data::time > (?)::time", Time.zone.parse(parameters['time']))
|
||||
when 'greater_than_or_equal_to'
|
||||
repository_rows.where("#{join_alias}.data::time >= ?", Time.zone.parse(parameters['time']))
|
||||
repository_rows.where("#{join_alias}.data::time >= (?)::time", Time.zone.parse(parameters['time']))
|
||||
when 'less_than'
|
||||
repository_rows.where("#{join_alias}.data::time < ?", Time.zone.parse(parameters['time']))
|
||||
repository_rows.where("#{join_alias}.data::time < (?)::time", Time.zone.parse(parameters['time']))
|
||||
when 'less_than_or_equal_to'
|
||||
repository_rows.where("#{join_alias}.data::time <= ?", Time.zone.parse(parameters['time']))
|
||||
repository_rows.where("#{join_alias}.data::time <= (?)::time", Time.zone.parse(parameters['time']))
|
||||
when 'between'
|
||||
repository_rows.where("#{join_alias}.data::time > ? AND #{join_alias}.data::time < ?",
|
||||
repository_rows.where("#{join_alias}.data::time > (?)::time AND #{join_alias}.data::time < (?)::time",
|
||||
Time.zone.parse(parameters['start_time']), Time.zone.parse(parameters['end_time']))
|
||||
else
|
||||
raise ArgumentError, 'Wrong operator for RepositoryTimeValue!'
|
||||
|
|
Loading…
Reference in a new issue