Commit f576360f authored by Adam Hegyi's avatar Adam Hegyi

Include state_id when gathering VSA data

This change syncs the `state_id` column during the value stream
analytics data collection process. To do that, we add the `state_id`
column to the VSA stage events tables.

Changelog: added
parent cb5df34a
......@@ -8,6 +8,9 @@ module Analytics
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
def self.issuable_id_column
:issue_id
end
......
......@@ -8,6 +8,9 @@ module Analytics
validates(*%i[stage_event_hash_id merge_request_id group_id project_id start_event_timestamp], presence: true)
alias_attribute :state, :state_id
enum state: MergeRequest.available_states, _suffix: true
def self.issuable_id_column
:merge_request_id
end
......
......@@ -15,6 +15,7 @@ module Analytics
:project_id,
:author_id,
:milestone_id,
:state_id,
:start_event_timestamp,
:end_event_timestamp
)
......@@ -31,6 +32,7 @@ module Analytics
project_id,
milestone_id,
author_id,
state_id,
start_event_timestamp,
end_event_timestamp
)
......@@ -39,10 +41,11 @@ module Analytics
DO UPDATE SET
group_id = excluded.group_id,
project_id = excluded.project_id,
start_event_timestamp = excluded.start_event_timestamp,
end_event_timestamp = excluded.end_event_timestamp,
milestone_id = excluded.milestone_id,
author_id = excluded.author_id
author_id = excluded.author_id,
state_id = excluded.state_id,
start_event_timestamp = excluded.start_event_timestamp,
end_event_timestamp = excluded.end_event_timestamp
SQL
result = connection.execute(query)
......
# frozen_string_literal: true
class AddStateIdToVsaIssueStageEvents < Gitlab::Database::Migration[1.0]
def change
add_column :analytics_cycle_analytics_issue_stage_events, :state_id, :smallint, default: 1, null: false
end
end
# frozen_string_literal: true
class AddStateIdToVsaMergeRequestStageEvents < Gitlab::Database::Migration[1.0]
def change
add_column :analytics_cycle_analytics_merge_request_stage_events, :state_id, :smallint, default: 1, null: false
end
end
56f86f2a20509f2052d0eab918a6d2bbb679d785cf5349916ba695aa92f0609f
\ No newline at end of file
1722382c5141157497f48b209c0fa60c5959fa16c53d09fb6e8e6b2cb6e6ab9b
\ No newline at end of file
......@@ -173,7 +173,8 @@ CREATE TABLE analytics_cycle_analytics_issue_stage_events (
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
)
PARTITION BY HASH (stage_event_hash_id);
......@@ -185,7 +186,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_00 FOR VALUES WITH (modulus 32, remainder 0);
......@@ -197,7 +199,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_01 FOR VALUES WITH (modulus 32, remainder 1);
......@@ -209,7 +212,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_02 FOR VALUES WITH (modulus 32, remainder 2);
......@@ -221,7 +225,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_03 FOR VALUES WITH (modulus 32, remainder 3);
......@@ -233,7 +238,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_04 FOR VALUES WITH (modulus 32, remainder 4);
......@@ -245,7 +251,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_05 FOR VALUES WITH (modulus 32, remainder 5);
......@@ -257,7 +264,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_06 FOR VALUES WITH (modulus 32, remainder 6);
......@@ -269,7 +277,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_07 FOR VALUES WITH (modulus 32, remainder 7);
......@@ -281,7 +290,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_08 FOR VALUES WITH (modulus 32, remainder 8);
......@@ -293,7 +303,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_09 FOR VALUES WITH (modulus 32, remainder 9);
......@@ -305,7 +316,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_10 FOR VALUES WITH (modulus 32, remainder 10);
......@@ -317,7 +329,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_11 FOR VALUES WITH (modulus 32, remainder 11);
......@@ -329,7 +342,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_12 FOR VALUES WITH (modulus 32, remainder 12);
......@@ -341,7 +355,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_13 FOR VALUES WITH (modulus 32, remainder 13);
......@@ -353,7 +368,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_14 FOR VALUES WITH (modulus 32, remainder 14);
......@@ -365,7 +381,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_15 FOR VALUES WITH (modulus 32, remainder 15);
......@@ -377,7 +394,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_16 FOR VALUES WITH (modulus 32, remainder 16);
......@@ -389,7 +407,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_17 FOR VALUES WITH (modulus 32, remainder 17);
......@@ -401,7 +420,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_18 FOR VALUES WITH (modulus 32, remainder 18);
......@@ -413,7 +433,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_19 FOR VALUES WITH (modulus 32, remainder 19);
......@@ -425,7 +446,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_20 FOR VALUES WITH (modulus 32, remainder 20);
......@@ -437,7 +459,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_21 FOR VALUES WITH (modulus 32, remainder 21);
......@@ -449,7 +472,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_22 FOR VALUES WITH (modulus 32, remainder 22);
......@@ -461,7 +485,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_23 FOR VALUES WITH (modulus 32, remainder 23);
......@@ -473,7 +498,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_24 FOR VALUES WITH (modulus 32, remainder 24);
......@@ -485,7 +511,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_25 FOR VALUES WITH (modulus 32, remainder 25);
......@@ -497,7 +524,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_26 FOR VALUES WITH (modulus 32, remainder 26);
......@@ -509,7 +537,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_27 FOR VALUES WITH (modulus 32, remainder 27);
......@@ -521,7 +550,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_28 FOR VALUES WITH (modulus 32, remainder 28);
......@@ -533,7 +563,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_29 FOR VALUES WITH (modulus 32, remainder 29);
......@@ -545,7 +576,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_30 FOR VALUES WITH (modulus 32, remainder 30);
......@@ -557,7 +589,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_even
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_issue_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_31 FOR VALUES WITH (modulus 32, remainder 31);
......@@ -569,7 +602,8 @@ CREATE TABLE analytics_cycle_analytics_merge_request_stage_events (
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
)
PARTITION BY HASH (stage_event_hash_id);
......@@ -581,7 +615,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_00 FOR VALUES WITH (modulus 32, remainder 0);
......@@ -593,7 +628,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_01 FOR VALUES WITH (modulus 32, remainder 1);
......@@ -605,7 +641,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_02 FOR VALUES WITH (modulus 32, remainder 2);
......@@ -617,7 +654,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_03 FOR VALUES WITH (modulus 32, remainder 3);
......@@ -629,7 +667,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_04 FOR VALUES WITH (modulus 32, remainder 4);
......@@ -641,7 +680,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_05 FOR VALUES WITH (modulus 32, remainder 5);
......@@ -653,7 +693,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_06 FOR VALUES WITH (modulus 32, remainder 6);
......@@ -665,7 +706,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_07 FOR VALUES WITH (modulus 32, remainder 7);
......@@ -677,7 +719,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_08 FOR VALUES WITH (modulus 32, remainder 8);
......@@ -689,7 +732,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_09 FOR VALUES WITH (modulus 32, remainder 9);
......@@ -701,7 +745,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_10 FOR VALUES WITH (modulus 32, remainder 10);
......@@ -713,7 +758,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_11 FOR VALUES WITH (modulus 32, remainder 11);
......@@ -725,7 +771,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_12 FOR VALUES WITH (modulus 32, remainder 12);
......@@ -737,7 +784,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_13 FOR VALUES WITH (modulus 32, remainder 13);
......@@ -749,7 +797,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_14 FOR VALUES WITH (modulus 32, remainder 14);
......@@ -761,7 +810,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_15 FOR VALUES WITH (modulus 32, remainder 15);
......@@ -773,7 +823,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_16 FOR VALUES WITH (modulus 32, remainder 16);
......@@ -785,7 +836,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_17 FOR VALUES WITH (modulus 32, remainder 17);
......@@ -797,7 +849,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_18 FOR VALUES WITH (modulus 32, remainder 18);
......@@ -809,7 +862,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_19 FOR VALUES WITH (modulus 32, remainder 19);
......@@ -821,7 +875,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_20 FOR VALUES WITH (modulus 32, remainder 20);
......@@ -833,7 +888,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_21 FOR VALUES WITH (modulus 32, remainder 21);
......@@ -845,7 +901,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_22 FOR VALUES WITH (modulus 32, remainder 22);
......@@ -857,7 +914,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_23 FOR VALUES WITH (modulus 32, remainder 23);
......@@ -869,7 +927,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_24 FOR VALUES WITH (modulus 32, remainder 24);
......@@ -881,7 +940,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_25 FOR VALUES WITH (modulus 32, remainder 25);
......@@ -893,7 +953,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_26 FOR VALUES WITH (modulus 32, remainder 26);
......@@ -905,7 +966,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_27 FOR VALUES WITH (modulus 32, remainder 27);
......@@ -917,7 +979,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_28 FOR VALUES WITH (modulus 32, remainder 28);
......@@ -929,7 +992,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_29 FOR VALUES WITH (modulus 32, remainder 29);
......@@ -941,7 +1005,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_30 FOR VALUES WITH (modulus 32, remainder 30);
......@@ -953,7 +1018,8 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone
end_event_timestamp timestamp with time zone,
state_id smallint DEFAULT 1 NOT NULL
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_31 FOR VALUES WITH (modulus 32, remainder 31);
......@@ -126,6 +126,7 @@ module Analytics
project_id: record['project_id'],
author_id: record['author_id'],
milestone_id: record['milestone_id'],
state_id: record['state_id'],
start_event_timestamp: record[event_column_name(stage.start_event)],
end_event_timestamp: record[event_column_name(stage.end_event)]
}
......@@ -146,6 +147,7 @@ module Analytics
model.arel_table[project_column].as('project_id'),
model.arel_table[:milestone_id],
model.arel_table[:author_id],
model.arel_table[:state_id],
Project.arel_table[:parent_id].as('group_id')
]
end
......
......@@ -103,7 +103,8 @@ RSpec.describe Analytics::CycleAnalytics::DataLoaderService do
mr.project.parent_id,
mr.project_id,
mr.created_at,
mr.metrics.merged_at
mr.metrics.merged_at,
mr.state_id
]
end
......@@ -116,7 +117,8 @@ RSpec.describe Analytics::CycleAnalytics::DataLoaderService do
event.group_id,
event.project_id,
event.start_event_timestamp,
event.end_event_timestamp
event.end_event_timestamp,
Analytics::CycleAnalytics::MergeRequestStageEvent.states[event.state_id]
]
end
......@@ -191,7 +193,8 @@ RSpec.describe Analytics::CycleAnalytics::DataLoaderService do
issue.project.parent_id,
issue.project_id,
issue.created_at,
issue.closed_at
issue.closed_at,
issue.state_id
]
end
......@@ -204,7 +207,8 @@ RSpec.describe Analytics::CycleAnalytics::DataLoaderService do
event.group_id,
event.project_id,
event.start_event_timestamp,
event.end_event_timestamp
event.end_event_timestamp,
Analytics::CycleAnalytics::IssueStageEvent.states[event.state_id]
]
end
......
......@@ -18,8 +18,8 @@ RSpec.describe 'Database schema' do
approvals: %w[user_id],
approver_groups: %w[target_id],
approvers: %w[target_id user_id],
analytics_cycle_analytics_merge_request_stage_events: %w[author_id group_id merge_request_id milestone_id project_id stage_event_hash_id],
analytics_cycle_analytics_issue_stage_events: %w[author_id group_id issue_id milestone_id project_id stage_event_hash_id],
analytics_cycle_analytics_merge_request_stage_events: %w[author_id group_id merge_request_id milestone_id project_id stage_event_hash_id state_id],
analytics_cycle_analytics_issue_stage_events: %w[author_id group_id issue_id milestone_id project_id stage_event_hash_id state_id],
audit_events: %w[author_id entity_id target_id],
award_emoji: %w[awardable_id user_id],
aws_roles: %w[role_external_id],
......
......@@ -9,5 +9,9 @@ RSpec.describe Analytics::CycleAnalytics::IssueStageEvent do
it { is_expected.to validate_presence_of(:project_id) }
it { is_expected.to validate_presence_of(:start_event_timestamp) }
it 'has state enum' do
expect(described_class.states).to eq(Issue.available_states)
end
it_behaves_like 'StageEventModel'
end
......@@ -9,5 +9,9 @@ RSpec.describe Analytics::CycleAnalytics::MergeRequestStageEvent do
it { is_expected.to validate_presence_of(:project_id) }
it { is_expected.to validate_presence_of(:start_event_timestamp) }
it 'has state enum' do
expect(described_class.states).to eq(MergeRequest.available_states)
end
it_behaves_like 'StageEventModel'
end
......@@ -12,6 +12,7 @@ RSpec.shared_examples 'StageEventModel' do
project_id: 4,
author_id: 5,
milestone_id: 6,
state_id: 1,
start_event_timestamp: time,
end_event_timestamp: time
},
......@@ -22,6 +23,7 @@ RSpec.shared_examples 'StageEventModel' do
project_id: 11,
author_id: 12,
milestone_id: 13,
state_id: 1,
start_event_timestamp: time,
end_event_timestamp: time
}
......@@ -36,6 +38,7 @@ RSpec.shared_examples 'StageEventModel' do
:project_id,
:milestone_id,
:author_id,
:state_id,
:start_event_timestamp,
:end_event_timestamp
]
......@@ -59,7 +62,13 @@ RSpec.shared_examples 'StageEventModel' do
upsert_data
output_data = described_class.all.map do |record|
column_order.map { |column| record[column] }
column_order.map do |column|
if column == :state_id
described_class.states[record[column]]
else
record[column]
end
end
end.sort
expect(input_data.map(&:values).sort).to eq(output_data)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment