Commit 66ba7cd7 authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Etienne Baqué

Remove incident labeled metric

Update yml for the metric

Remove usage of incident label class

Changelog: removed
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/78447
parent 532e33aa
...@@ -121,7 +121,6 @@ class Issue < ApplicationRecord ...@@ -121,7 +121,6 @@ class Issue < ApplicationRecord
scope :preload_associated_models, -> { preload(:assignees, :labels, project: :namespace) } scope :preload_associated_models, -> { preload(:assignees, :labels, project: :namespace) }
scope :with_web_entity_associations, -> { preload(:author, project: [:project_feature, :route, namespace: :route]) } scope :with_web_entity_associations, -> { preload(:author, project: [:project_feature, :route, namespace: :route]) }
scope :preload_awardable, -> { preload(:award_emoji) } scope :preload_awardable, -> { preload(:award_emoji) }
scope :with_label_attributes, ->(label_attributes) { joins(:labels).where(labels: label_attributes) }
scope :with_alert_management_alerts, -> { joins(:alert_management_alert) } scope :with_alert_management_alerts, -> { joins(:alert_management_alert) }
scope :with_prometheus_alert_events, -> { joins(:issues_prometheus_alert_events) } scope :with_prometheus_alert_events, -> { joins(:issues_prometheus_alert_events) }
scope :with_self_managed_prometheus_alert_events, -> { joins(:issues_self_managed_prometheus_alert_events) } scope :with_self_managed_prometheus_alert_events, -> { joins(:issues_self_managed_prometheus_alert_events) }
......
# frozen_string_literal: true
module IncidentManagement
class CreateIncidentLabelService < BaseService
LABEL_PROPERTIES = {
title: 'incident',
color: '#CC0033',
description: <<~DESCRIPTION.chomp
Denotes a disruption to IT services and \
the associated issues require immediate attention
DESCRIPTION
}.freeze
def execute
label = Labels::FindOrCreateService
.new(current_user, project, **LABEL_PROPERTIES)
.execute(skip_authorization: true)
ServiceResponse.success(payload: { label: label })
end
end
end
...@@ -7,7 +7,7 @@ product_stage: monitor ...@@ -7,7 +7,7 @@ product_stage: monitor
product_group: group::monitor product_group: group::monitor
product_category: incident_management product_category: incident_management
value_type: number value_type: number
status: active status: removed
time_frame: all time_frame: all
data_source: database data_source: database
distribution: distribution:
...@@ -19,3 +19,4 @@ tier: ...@@ -19,3 +19,4 @@ tier:
- ultimate - ultimate
performance_indicator_type: [] performance_indicator_type: []
milestone: "<13.9" milestone: "<13.9"
milestone_removed: "14.8"
...@@ -131,7 +131,6 @@ module Gitlab ...@@ -131,7 +131,6 @@ module Gitlab
issues_created_manually_from_alerts: issues_created_manually_from_alerts, issues_created_manually_from_alerts: issues_created_manually_from_alerts,
incident_issues: count(::Issue.incident, start: minimum_id(Issue), finish: maximum_id(Issue)), incident_issues: count(::Issue.incident, start: minimum_id(Issue), finish: maximum_id(Issue)),
alert_bot_incident_issues: count(::Issue.authored(::User.alert_bot), start: minimum_id(Issue), finish: maximum_id(Issue)), alert_bot_incident_issues: count(::Issue.authored(::User.alert_bot), start: minimum_id(Issue), finish: maximum_id(Issue)),
incident_labeled_issues: count(::Issue.with_label_attributes(::IncidentManagement::CreateIncidentLabelService::LABEL_PROPERTIES), start: minimum_id(Issue), finish: maximum_id(Issue)),
keys: count(Key), keys: count(Key),
label_lists: count(List.label), label_lists: count(List.label),
lfs_objects: count(LfsObject), lfs_objects: count(LfsObject),
......
...@@ -18,13 +18,6 @@ FactoryBot.define do ...@@ -18,13 +18,6 @@ FactoryBot.define do
title { "#{prefix}::#{generate(:label_title)}" } title { "#{prefix}::#{generate(:label_title)}" }
end end
trait :incident do
properties = IncidentManagement::CreateIncidentLabelService::LABEL_PROPERTIES
title { properties.fetch(:title) }
description { properties.fetch(:description) }
color { properties.fetch(:color) }
end
factory :label, traits: [:base_label], class: 'ProjectLabel' do factory :label, traits: [:base_label], class: 'ProjectLabel' do
project project
......
...@@ -58,14 +58,6 @@ FactoryBot.define do ...@@ -58,14 +58,6 @@ FactoryBot.define do
# Tracing # Tracing
create(:project_tracing_setting, project: projects[0]) create(:project_tracing_setting, project: projects[0])
# Incident Labeled Issues
incident_label = create(:label, :incident, project: projects[0])
create(:labeled_issue, project: projects[0], labels: [incident_label])
incident_label_scoped_to_project = create(:label, :incident, project: projects[1])
incident_label_scoped_to_group = create(:group_label, :incident, group: group)
create(:labeled_issue, project: projects[1], labels: [incident_label_scoped_to_project])
create(:labeled_issue, project: projects[1], labels: [incident_label_scoped_to_group])
# Alert Issues # Alert Issues
create(:alert_management_alert, issue: issues[0], project: projects[0]) create(:alert_management_alert, issue: issues[0], project: projects[0])
create(:alert_management_alert, issue: alert_bot_issues[0], project: projects[0]) create(:alert_management_alert, issue: alert_bot_issues[0], project: projects[0])
......
...@@ -556,8 +556,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -556,8 +556,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
expect(count_data[:issues_created_from_alerts]).to eq(3) expect(count_data[:issues_created_from_alerts]).to eq(3)
expect(count_data[:issues_created_manually_from_alerts]).to eq(1) expect(count_data[:issues_created_manually_from_alerts]).to eq(1)
expect(count_data[:alert_bot_incident_issues]).to eq(4) expect(count_data[:alert_bot_incident_issues]).to eq(4)
expect(count_data[:incident_labeled_issues]).to eq(3)
expect(count_data[:clusters_enabled]).to eq(6) expect(count_data[:clusters_enabled]).to eq(6)
expect(count_data[:project_clusters_enabled]).to eq(4) expect(count_data[:project_clusters_enabled]).to eq(4)
expect(count_data[:group_clusters_enabled]).to eq(1) expect(count_data[:group_clusters_enabled]).to eq(1)
......
...@@ -1431,26 +1431,6 @@ RSpec.describe Issue do ...@@ -1431,26 +1431,6 @@ RSpec.describe Issue do
end end
end end
describe '.with_label_attributes' do
subject { described_class.with_label_attributes(label_attributes) }
let(:label_attributes) { { title: 'hello world', description: 'hi' } }
it 'gets issues with given label attributes' do
label = create(:label, **label_attributes)
labeled_issue = create(:labeled_issue, project: label.project, labels: [label])
expect(subject).to include(labeled_issue)
end
it 'excludes issues without given label attributes' do
label = create(:label, title: 'GitLab', description: 'tanuki')
labeled_issue = create(:labeled_issue, project: label.project, labels: [label])
expect(subject).not_to include(labeled_issue)
end
end
describe 'banzai_render_context' do describe 'banzai_render_context' do
let(:project) { build(:project_empty_repo) } let(:project) { build(:project_empty_repo) }
let(:issue) { build :issue, project: project } let(:issue) { build :issue, project: project }
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe IncidentManagement::CreateIncidentLabelService do
it_behaves_like 'incident management label service'
end
...@@ -14,7 +14,6 @@ RSpec.describe IncidentManagement::Incidents::CreateService do ...@@ -14,7 +14,6 @@ RSpec.describe IncidentManagement::Incidents::CreateService do
context 'when incident has title and description' do context 'when incident has title and description' do
let(:title) { 'Incident title' } let(:title) { 'Incident title' }
let(:new_issue) { Issue.last! } let(:new_issue) { Issue.last! }
let(:label_title) { attributes_for(:label, :incident)[:title] }
it 'responds with success' do it 'responds with success' do
expect(create_incident).to be_success expect(create_incident).to be_success
...@@ -38,8 +37,6 @@ RSpec.describe IncidentManagement::Incidents::CreateService do ...@@ -38,8 +37,6 @@ RSpec.describe IncidentManagement::Incidents::CreateService do
end end
let(:issue) { new_issue } let(:issue) { new_issue }
include_examples 'does not have incident label'
end end
context 'with default severity' do context 'with default severity' do
...@@ -69,20 +66,6 @@ RSpec.describe IncidentManagement::Incidents::CreateService do ...@@ -69,20 +66,6 @@ RSpec.describe IncidentManagement::Incidents::CreateService do
end end
end end
end end
context 'when incident label does not exists' do
it 'does not create incident label' do
expect { create_incident }.to not_change { project.labels.where(title: label_title).count }
end
end
context 'when incident label already exists' do
let!(:label) { create(:label, project: project, title: label_title) }
it 'does not create new labels' do
expect { create_incident }.not_to change(Label, :count)
end
end
end end
context 'when incident has no title' do context 'when incident has no title' do
......
...@@ -100,7 +100,6 @@ RSpec.describe Issues::CreateService do ...@@ -100,7 +100,6 @@ RSpec.describe Issues::CreateService do
end end
let(:current_user) { user } let(:current_user) { user }
let(:incident_label_attributes) { attributes_for(:label, :incident) }
subject { issue } subject { issue }
...@@ -114,12 +113,6 @@ RSpec.describe Issues::CreateService do ...@@ -114,12 +113,6 @@ RSpec.describe Issues::CreateService do
end end
it_behaves_like 'incident issue' it_behaves_like 'incident issue'
it_behaves_like 'does not have incident label'
it 'does not create an incident label' do
expect { subject }
.to not_change { Label.where(incident_label_attributes).count }
end
it 'calls IncidentManagement::Incidents::CreateEscalationStatusService' do it 'calls IncidentManagement::Incidents::CreateEscalationStatusService' do
expect_next(::IncidentManagement::IssuableEscalationStatuses::CreateService, a_kind_of(Issue)) expect_next(::IncidentManagement::IssuableEscalationStatuses::CreateService, a_kind_of(Issue))
......
...@@ -28,28 +28,15 @@ end ...@@ -28,28 +28,15 @@ end
# #
# include_examples 'not an incident issue' # include_examples 'not an incident issue'
RSpec.shared_examples 'not an incident issue' do RSpec.shared_examples 'not an incident issue' do
let(:label_properties) { attributes_for(:label, :incident) }
it 'has not incident as issue type' do it 'has not incident as issue type' do
expect(issue.issue_type).not_to eq('incident') expect(issue.issue_type).not_to eq('incident')
expect(issue.work_item_type.base_type).not_to eq('incident') expect(issue.work_item_type.base_type).not_to eq('incident')
end end
it_behaves_like 'does not have incident label'
end
RSpec.shared_examples 'does not have incident label' do
let(:label_properties) { attributes_for(:label, :incident) }
it 'has not an incident label' do
expect(issue.labels).not_to include(have_attributes(label_properties))
end
end end
# This shared example is to test the execution of incident management label services # This shared example is to test the execution of incident management label services
# For example: # For example:
# - IncidentManagement::CreateIncidentSlaExceededLabelService # - IncidentManagement::CreateIncidentSlaExceededLabelService
# - IncidentManagement::CreateIncidentLabelService
# It doesn't require any defined variables # It doesn't require any defined variables
......
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