summaryrefslogtreecommitdiff
path: root/app/graphql/resolvers/concerns/issues/look_ahead_preloads.rb
blob: 2ea7a02bf151de12f718c9897cafc7c77bb5c159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true

module Issues
  module LookAheadPreloads
    extend ActiveSupport::Concern

    prepended do
      include ::LooksAhead
    end

    private

    def unconditional_includes
      [
        {
          project: [:project_feature, :group]
        },
        :author
      ]
    end

    def preloads
      preload_hash = {
        alert_management_alert: [:alert_management_alert],
        assignees: [:assignees],
        participants: Issue.participant_includes,
        timelogs: [:timelogs],
        customer_relations_contacts: { customer_relations_contacts: [:group] },
        escalation_status: [:incident_management_issuable_escalation_status]
      }
      preload_hash[:type] = :work_item_type if Feature.enabled?(:issue_type_uses_work_item_types_table)

      preload_hash
    end
  end
end

Issues::LookAheadPreloads.prepend_mod