Class: Collavre::Creatives::IndexQuery

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

Defined Under Namespace

Classes: Result

Constant Summary collapse

SIMPLE_SEARCH_LIMIT =

Cap flat search results for the lightweight picker popup (simple mode). The full-page search (no ‘simple` flag) is intentionally unbounded.

50
PERMISSION_FILTER_BATCH =

Permission-check matched rows in rank order in slices of this size, so a heavily-matched query only checks the prefix needed to fill the cap rather than its entire match set.

200
COMMENT_CHATS_PER_PAGE =

Page size for the top-nav “Chats” feed (the comment filter). The list is unbounded by nature (it grows with every commented creative), so it is paginated instead of materialized whole.

30

Instance Method Summary collapse

Constructor Details

#initialize(user:, params: {}) ⇒ IndexQuery

Returns a new instance of IndexQuery.



30
31
32
33
# File 'app/services/collavre/creatives/index_query.rb', line 30

def initialize(user:, params: {})
  @user = user
  @params = params.with_indifferent_access
end

Instance Method Details

#callObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/services/collavre/creatives/index_query.rb', line 35

def call
  result = resolve_creatives
  shared_creative = result[:parent] || result[:creatives]&.first
  shared_list = shared_creative ? shared_creative.all_shared_users : []

  Result.new(
    creatives: result[:creatives],
    parent_creative: result[:parent],
    shared_creative: shared_creative,
    shared_list: shared_list,
    overall_progress: result[:overall_progress] || 0,
    allowed_creative_ids: result[:allowed_ids],
    progress_map: result[:progress_map],
    pagination: result[:pagination]
  )
end