Welcome to mirror list, hosted at ThFree Co, Russian Federation.

issue_stage_event.rb « cycle_analytics « analytics « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1a8f1b7c84a8dea93e17efc811326289524c2b89 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# frozen_string_literal: true

module Analytics
  module CycleAnalytics
    class IssueStageEvent < ApplicationRecord
      include StageEventModel
      extend SuppressCompositePrimaryKeyWarning

      validates(*%i[stage_event_hash_id issue_id group_id project_id start_event_timestamp], presence: true)

      alias_attribute :state, :state_id
      enum state: Issue.available_states, _suffix: true

      scope :assigned_to, ->(user) do
        assignees_class = IssueAssignee
        condition = assignees_class.where(user_id: user).where(arel_table[:issue_id].eq(assignees_class.arel_table[:issue_id]))
        where(condition.arel.exists)
      end

      class << self
        def project_column
          :project_id
        end

        def issuable_id_column
          :issue_id
        end

        def issuable_model
          ::Issue
        end

        def select_columns
          [
            *super,
            issuable_model.arel_table[:weight],
            issuable_model.arel_table[:sprint_id]
          ]
        end

        def column_list
          [
            *super,
            :weight,
            :sprint_id
          ]
        end

        def insert_column_list
          [
            *super,
            :weight,
            :sprint_id
          ]
        end
      end
    end
  end
end
Analytics::CycleAnalytics::IssueStageEvent.prepend_mod_with('Analytics::CycleAnalytics::IssueStageEvent')