Class: Collavre::Creatives::Filters::AssigneeFilter
- Inherits:
-
BaseFilter
- Object
- BaseFilter
- Collavre::Creatives::Filters::AssigneeFilter
show all
- Defined in:
- app/services/collavre/creatives/filters/assignee_filter.rb
Instance Method Summary
collapse
Methods inherited from BaseFilter
#initialize
Instance Method Details
#active? ⇒ Boolean
5
6
7
|
# File 'app/services/collavre/creatives/filters/assignee_filter.rb', line 5
def active?
params[:assignee_id].present? || params[:unassigned].present?
end
|
#match ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/services/collavre/creatives/filters/assignee_filter.rb', line 9
def match
if params[:unassigned] == "true"
with_null_owner = scope.left_joins(tags: :label)
.where(labels: { owner_id: nil })
.pluck(:id)
without_tags = scope.left_joins(:tags)
.where(tags: { id: nil })
.pluck(:id)
(with_null_owner + without_tags).uniq
else
assignee_ids = Array(params[:assignee_id]).map(&:to_i)
scope.joins(tags: :label)
.where(labels: { owner_id: assignee_ids })
.distinct
.pluck(:id)
end
end
|