Class: Boards::BaseItemsListService

Inherits:
BaseService show all
Includes:
ActiveRecord::ConnectionAdapters::Quoting, Gitlab::Utils::StrongMemoize
Defined in:
app/services/boards/base_items_list_service.rb

Direct Known Subclasses

Issues::ListService

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #parent

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from BaseService

#initialize

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from Boards::BaseService

Instance Method Details

#executeObject


8
9
10
11
12
# File 'app/services/boards/base_items_list_service.rb', line 8

def execute
  items = init_collection

  order(items)
end

#metadata(required_fields = [:issue_count, :total_issue_weight]) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


15
16
17
18
19
20
21
22
23
24
25
# File 'app/services/boards/base_items_list_service.rb', line 15

def (required_fields = [:issue_count, :total_issue_weight])
  fields = (required_fields)
  keys = fields.keys
  # TODO: eliminate need for SQL literal fragment
  columns = Arel.sql(fields.values_at(*keys).join(', '))
  results = item_model.where(id: collection_ids)
  results = query_additions(results, required_fields)
  results = results.select(columns)

  Hash[keys.zip(results.pluck(columns).flatten)]
end