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:
Soufiane 2023-02-21 14:36:24 +01:00 committed by GitHub
parent f21e5edf55
commit c88e2df19c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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