Class: Collavre::Creatives::FilterPipeline

Inherits:
Object
  • Object
show all
Defined in:
app/services/collavre/creatives/filter_pipeline.rb

Defined Under Namespace

Classes: Result

Constant Summary collapse

FILTERS =

필터 클래스 목록 - 순서대로 적용

[
  Filters::ProgressFilter,
  Filters::TagFilter,
  Filters::SearchFilter,
  Filters::CommentFilter,
  Filters::DateFilter,
  Filters::AssigneeFilter
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(user:, params:, scope:) ⇒ FilterPipeline

Returns a new instance of FilterPipeline.



22
23
24
25
26
# File 'app/services/collavre/creatives/filter_pipeline.rb', line 22

def initialize(user:, params:, scope:)
  @user = user
  @params = params
  @scope = scope
end

Instance Method Details

#any_filter_active?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'app/services/collavre/creatives/filter_pipeline.rb', line 48

def any_filter_active?
  FILTERS.any? { |klass| klass.new(params: params, scope: scope).active? }
end

#callObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/services/collavre/creatives/filter_pipeline.rb', line 28

def call
  matched_ids = apply_filters
  return empty_result if matched_ids.empty?

  # 조상 포함
  allowed_ids = resolve_ancestors(matched_ids)

  # O(1) 권한 필터링
  allowed_ids = filter_by_permission(allowed_ids)

  progress_map, overall = calculate_progress(allowed_ids, matched_ids)

  Result.new(
    matched_ids: matched_ids.to_set,
    allowed_ids: allowed_ids.map(&:to_s).to_set,
    progress_map: progress_map,
    overall_progress: overall
  )
end