blob: 0e9a3fb5e8cc31ee59eed7fb7895c1f5b4234d47 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# frozen_string_literal: true
module UpdatedAtFilter
def by_updated_at(items)
updated_before = params[:updated_before]&.in_time_zone
updated_after = params[:updated_after]&.in_time_zone
return items.none if [updated_before, updated_after].all?(&:present?) && updated_before < updated_after
items = items.updated_before(updated_before) if updated_before.present?
items = items.updated_after(updated_after) if updated_after.present?
items
end
end
|