Commit 15c3d420 authored by Sarah Yasonik's avatar Sarah Yasonik Committed by Peter Leitzen

Add count of projects with new incidents to usage ping

parent 79f7a27c
---
title: Add new incident counts to usage ping
merge_request: 46602
author:
type: changed
# frozen_string_literal: true
class AddIndexToIncidentIssuesOnProjectAndCreatedAt < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
INCIDENT_TYPE = 1
OLD_INDEX_NAME = 'index_issues_project_id_issue_type_incident'
NEW_INDEX_NAME = 'index_issues_on_project_id_and_created_at_issue_type_incident'
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :issues,
[:project_id, :created_at],
where: "issue_type = #{INCIDENT_TYPE}",
name: NEW_INDEX_NAME
remove_concurrent_index_by_name :issues, OLD_INDEX_NAME
end
def down
add_concurrent_index :issues,
:project_id,
where: "issue_type = #{INCIDENT_TYPE}",
name: OLD_INDEX_NAME
remove_concurrent_index_by_name :issues, NEW_INDEX_NAME
end
end
040e73d690cb315627fe16c931273aa1f86dfabb481dc2086f787d067b87642f
\ No newline at end of file
......@@ -21029,6 +21029,8 @@ CREATE INDEX index_issues_on_moved_to_id ON issues USING btree (moved_to_id) WHE
CREATE INDEX index_issues_on_project_id_and_closed_at ON issues USING btree (project_id, closed_at);
CREATE INDEX index_issues_on_project_id_and_created_at_issue_type_incident ON issues USING btree (project_id, created_at) WHERE (issue_type = 1);
CREATE UNIQUE INDEX index_issues_on_project_id_and_external_key ON issues USING btree (project_id, external_key) WHERE (external_key IS NOT NULL);
CREATE UNIQUE INDEX index_issues_on_project_id_and_iid ON issues USING btree (project_id, iid);
......@@ -21043,8 +21045,6 @@ CREATE INDEX index_issues_on_updated_at ON issues USING btree (updated_at);
CREATE INDEX index_issues_on_updated_by_id ON issues USING btree (updated_by_id) WHERE (updated_by_id IS NOT NULL);
CREATE INDEX index_issues_project_id_issue_type_incident ON issues USING btree (project_id) WHERE (issue_type = 1);
CREATE UNIQUE INDEX index_jira_connect_installations_on_client_key ON jira_connect_installations USING btree (client_key);
CREATE INDEX index_jira_connect_subscriptions_on_namespace_id ON jira_connect_subscriptions USING btree (namespace_id);
......
......@@ -632,7 +632,9 @@ module Gitlab
start: user_minimum_id,
finish: user_maximum_id),
projects_with_tracing_enabled: distinct_count(::Project.with_tracing_enabled.where(time_period), :creator_id),
projects_with_error_tracking_enabled: distinct_count(::Project.with_enabled_error_tracking.where(time_period), :creator_id)
projects_with_error_tracking_enabled: distinct_count(::Project.with_enabled_error_tracking.where(time_period), :creator_id),
projects_with_incidents: distinct_count(::Issue.incident.where(time_period), :project_id),
projects_with_alert_incidents: distinct_count(::Issue.incident.with_alert_management_alerts.where(time_period), :project_id)
}
end
# rubocop: enable CodeReuse/ActiveRecord
......
......@@ -299,6 +299,8 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
create(:clusters_applications_prometheus, :installed, cluster: cluster)
create(:project_tracing_setting)
create(:project_error_tracking_setting)
create(:incident)
create(:incident, alert_management_alert: create(:alert_management_alert))
end
expect(described_class.usage_activity_by_stage_monitor({})).to include(
......@@ -306,7 +308,9 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
clusters_applications_prometheus: 2,
operations_dashboard_default_dashboard: 2,
projects_with_tracing_enabled: 2,
projects_with_error_tracking_enabled: 2
projects_with_error_tracking_enabled: 2,
projects_with_incidents: 4,
projects_with_alert_incidents: 2
)
expect(described_class.usage_activity_by_stage_monitor(described_class.last_28_days_time_period)).to include(
......@@ -314,7 +318,9 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
clusters_applications_prometheus: 1,
operations_dashboard_default_dashboard: 1,
projects_with_tracing_enabled: 1,
projects_with_error_tracking_enabled: 1
projects_with_error_tracking_enabled: 1,
projects_with_incidents: 2,
projects_with_alert_incidents: 1
)
end
end
......
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