mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-25 01:03:18 +08:00
Fix filter_date action when only one date is present [SCI-7942] (#5005)
Fix filter_date action when only one date is present [SCI-7942]
This commit is contained in:
parent
f21e5edf55
commit
c88e2df19c
1 changed files with 12 additions and 3 deletions
|
@ -26,9 +26,18 @@ module Activities
|
|||
|
||||
def filter_date!
|
||||
@activity_filters = @activity_filters.where(
|
||||
"((filter ->> 'from_date') = '' AND (filter ->> 'to_date') = '') OR " \
|
||||
"((?)::date BETWEEN (filter ->> 'from_date')::date AND (filter ->> 'to_date')::date)",
|
||||
@activity.created_at.to_date
|
||||
"(CASE "\
|
||||
"WHEN (filter ->> 'to_date') = '' " \
|
||||
"THEN :date >= '-infinity'::date " \
|
||||
"ELSE :date >= (filter ->> 'to_date')::date " \
|
||||
"END) " \
|
||||
" AND " \
|
||||
"(CASE "\
|
||||
"WHEN (filter ->> 'from_date') = '' " \
|
||||
"THEN :date <= 'infinity'::date " \
|
||||
"ELSE :date <= (filter ->> 'from_date')::date "\
|
||||
"END)",
|
||||
date: @activity.created_at.to_date
|
||||
)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue