mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-17 22:42:22 +08:00
Wrap timestamp filter params in the filter attribute [SCI-8738-updated]
This commit is contained in:
parent
ab758c747f
commit
02115cf967
1 changed files with 8 additions and 4 deletions
|
|
@ -246,12 +246,16 @@ module Api
|
|||
end
|
||||
|
||||
def timestamps_filter(records)
|
||||
from = params.dig(:created_at, :from).present? ? Date.parse(params.dig(:created_at, :from)) : nil
|
||||
to = params.dig(:created_at, :to).present? ? Date.parse(params.dig(:created_at, :to)) : nil
|
||||
from = Date.parse(params.dig(:filter, :created_at, :from)) if
|
||||
params.dig(:filter, :created_at, :from).present?
|
||||
to = Date.parse(params.dig(:filter, :created_at, :to)) if
|
||||
params.dig(:filter, :created_at, :to).present?
|
||||
records = records.where(created_at: (from..to)) if from || to
|
||||
|
||||
from = params.dig(:updated_at, :from).present? ? Date.parse(params.dig(:updated_at, :from)) : nil
|
||||
to = params.dig(:updated_at, :to).present? ? Date.parse(params.dig(:updated_at, :to)) : nil
|
||||
from = Date.parse(params.dig(:filter, :updated_at, :from)) if
|
||||
params.dig(:filter, :updated_at, :from).present?
|
||||
to = Date.parse(params.dig(:filter, :updated_at, :to)) if
|
||||
params.dig(:filter, :updated_at, :to).present?
|
||||
records = records.where(updated_at: (from..to)) if from || to
|
||||
|
||||
records
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue