Commit 1b3f0d30 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Remove track_issue_weight_change_events flag

This feature flag has been enabled by default for a while now
parent 49d7ee1e
...@@ -773,7 +773,6 @@ Rails/SaveBang: ...@@ -773,7 +773,6 @@ Rails/SaveBang:
- 'ee/spec/services/ee/merge_requests/update_service_spec.rb' - 'ee/spec/services/ee/merge_requests/update_service_spec.rb'
- 'ee/spec/services/ee/notes/quick_actions_service_spec.rb' - 'ee/spec/services/ee/notes/quick_actions_service_spec.rb'
- 'ee/spec/services/ee/notification_service_spec.rb' - 'ee/spec/services/ee/notification_service_spec.rb'
- 'ee/spec/services/ee/resource_events/change_weight_service_spec.rb'
- 'ee/spec/services/epic_links/create_service_spec.rb' - 'ee/spec/services/epic_links/create_service_spec.rb'
- 'ee/spec/services/epics/close_service_spec.rb' - 'ee/spec/services/epics/close_service_spec.rb'
- 'ee/spec/services/epics/issue_promote_service_spec.rb' - 'ee/spec/services/epics/issue_promote_service_spec.rb'
......
...@@ -46,11 +46,7 @@ module EE ...@@ -46,11 +46,7 @@ module EE
def handle_weight_change def handle_weight_change
return unless issuable.previous_changes.include?('weight') return unless issuable.previous_changes.include?('weight')
if weight_changes_tracking_enabled? ::ResourceEvents::ChangeWeightService.new([issuable], current_user, Time.current).execute
EE::ResourceEvents::ChangeWeightService.new([issuable], current_user, Time.current).execute
else
::SystemNoteService.change_weight_note(issuable, issuable.project, current_user)
end
end end
def handle_health_status_change def handle_health_status_change
...@@ -59,10 +55,6 @@ module EE ...@@ -59,10 +55,6 @@ module EE
::SystemNoteService.change_health_status_note(issuable, issuable.project, current_user) ::SystemNoteService.change_health_status_note(issuable, issuable.project, current_user)
end end
def weight_changes_tracking_enabled?
!issuable.is_a?(Epic) && ::Feature.enabled?(:track_issue_weight_change_events, issuable.project, default_enabled: true)
end
def iteration_changes_tracking_enabled? def iteration_changes_tracking_enabled?
::Feature.enabled?(:track_iteration_change_events, issuable.project, default_enabled: true) ::Feature.enabled?(:track_iteration_change_events, issuable.project, default_enabled: true)
end end
......
...@@ -40,23 +40,6 @@ module EE ...@@ -40,23 +40,6 @@ module EE
issuables_service(noteable, noteable.project, author).change_iteration(iteration) issuables_service(noteable, noteable.project, author).change_iteration(iteration)
end end
# Called when the weight of a Noteable is changed
#
# noteable - Noteable object
# project - Project owning noteable
# author - User performing the change
#
# Example Note text:
#
# "removed the weight"
#
# "changed weight to 4"
#
# Returns the created Note object
def change_weight_note(noteable, project, author)
issuables_service(noteable, project, author).change_weight_note
end
# Called when the health_stauts of an Issue is changed # Called when the health_stauts of an Issue is changed
# #
# noteable - Noteable object # noteable - Noteable object
......
...@@ -2,21 +2,6 @@ ...@@ -2,21 +2,6 @@
module EE module EE
module SystemNotes module SystemNotes
module IssuablesService module IssuablesService
# Called when the weight of a Noteable is changed
#
# Example Note text:
#
# "removed the weight"
#
# "changed weight to 4"
#
# Returns the created Note object
def change_weight_note
body = noteable.weight ? "changed weight to **#{noteable.weight}**" : 'removed the weight'
create_note(NoteSummary.new(noteable, project, author, body, action: 'weight'))
end
# Called when the health_status of an Issue is changed # Called when the health_status of an Issue is changed
# #
# Example Note text: # Example Note text:
......
# frozen_string_literal: true
module ResourceEvents
class ChangeWeightService
attr_reader :resources, :user, :event_created_at
def initialize(resources, user, created_at)
@resources = resources
@user = user
@event_created_at = created_at
end
def execute
unless resource_weight_changes.empty?
::Gitlab::Database.bulk_insert(ResourceWeightEvent.table_name, resource_weight_changes) # rubocop:disable Gitlab/BulkInsert
resources.each(&:expire_note_etag_cache)
end
end
private
def resource_weight_changes
@weight_changes ||= resources.map do |resource|
changes = []
base_data = { user_id: user.id, issue_id: resource.id }
changes << base_data.merge({ weight: resource.previous_weight, created_at: resource.previous_updated_at }) if resource.first_weight_event?
changes << base_data.merge({ weight: resource.weight, created_at: event_created_at })
end.flatten
end
end
end
...@@ -423,24 +423,6 @@ RSpec.describe API::Issues, :mailer do ...@@ -423,24 +423,6 @@ RSpec.describe API::Issues, :mailer do
expect(issue.reload.read_attribute(:weight)).to be_nil expect(issue.reload.read_attribute(:weight)).to be_nil
end end
end end
context 'when issue weight tracking feature flag is not active' do
before do
stub_feature_flags(track_issue_weight_change_events: false)
end
it 'does not create a ResourceWeightEvent' do
expect do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { weight: 9 }
end.not_to change { ResourceWeightEvent.count }
end
it 'creates a system note' do
expect do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { weight: 9 }
end.to change { Note.count }.by(1)
end
end
end end
describe 'PUT /projects/:id/issues/:issue_id to update epic' do describe 'PUT /projects/:id/issues/:issue_id to update epic' do
......
...@@ -115,34 +115,12 @@ RSpec.describe Issuable::CommonSystemNotesService do ...@@ -115,34 +115,12 @@ RSpec.describe Issuable::CommonSystemNotesService do
issuable.update(weight: 5, health_status: 'at_risk') issuable.update(weight: 5, health_status: 'at_risk')
end end
context 'when resource weight event tracking is enabled' do it 'creates a resource weight event' do
before do expect { subject }.to change { ResourceWeightEvent.count }
stub_feature_flags(track_issue_weight_change_events: true)
end
it 'creates a resource weight event' do
expect { subject }.to change { ResourceWeightEvent.count }
end
it 'does not create a system note' do
expect { subject }.not_to change { Note.count }
end
end end
context 'when resource weight event tracking is disabled' do it 'does not create a system note' do
before do expect { subject }.not_to change { Note.count }
stub_feature_flags(track_issue_weight_change_events: false)
end
it 'does not created a resource weight event' do
expect { subject }.not_to change { ResourceWeightEvent.count }
end
it 'does create a system note' do
expect { subject }.to change { Note.count }.from(0).to(1)
expect(Note.first.note).to eq('changed weight to **5**')
end
end end
it_behaves_like 'issuable iteration changed' it_behaves_like 'issuable iteration changed'
......
...@@ -13,36 +13,6 @@ RSpec.describe ::SystemNotes::IssuablesService do ...@@ -13,36 +13,6 @@ RSpec.describe ::SystemNotes::IssuablesService do
let(:service) { described_class.new(noteable: noteable, project: project, author: author) } let(:service) { described_class.new(noteable: noteable, project: project, author: author) }
describe '#change_weight_note' do
context 'when weight changed' do
let(:noteable) { create(:issue, project: project, title: 'Lorem ipsum', weight: 4) }
subject { service.change_weight_note }
it_behaves_like 'a system note' do
let(:action) { 'weight' }
end
it 'sets the note text' do
expect(subject.note).to eq "changed weight to **4**"
end
end
context 'when weight removed' do
let(:noteable) { create(:issue, project: project, title: 'Lorem ipsum', weight: nil) }
subject { service.change_weight_note }
it_behaves_like 'a system note' do
let(:action) { 'weight' }
end
it 'sets the note text' do
expect(subject.note).to eq 'removed the weight'
end
end
end
describe '#change_health_status_note' do describe '#change_health_status_note' do
context 'when health_status changed' do context 'when health_status changed' do
let(:noteable) { create(:issue, project: project, title: 'Lorem ipsum', health_status: 'at_risk') } let(:noteable) { create(:issue, project: project, title: 'Lorem ipsum', health_status: 'at_risk') }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe EE::ResourceEvents::ChangeWeightService do RSpec.describe ResourceEvents::ChangeWeightService do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:issue) { create(:issue, weight: 3) } let(:issue) { create(:issue, weight: 3) }
...@@ -35,7 +35,7 @@ RSpec.describe EE::ResourceEvents::ChangeWeightService do ...@@ -35,7 +35,7 @@ RSpec.describe EE::ResourceEvents::ChangeWeightService do
context 'when there is no existing weight event record' do context 'when there is no existing weight event record' do
before do before do
ResourceWeightEvent.delete_all ResourceWeightEvent.delete_all
issue.update(weight: 5, updated_at: 10.seconds.ago) issue.update!(weight: 5, updated_at: 10.seconds.ago)
end end
it 'creates the expected event records' do it 'creates the expected event records' do
......
...@@ -14,16 +14,6 @@ RSpec.describe SystemNoteService do ...@@ -14,16 +14,6 @@ RSpec.describe SystemNoteService do
let_it_be(:issue) { noteable } let_it_be(:issue) { noteable }
let_it_be(:epic) { create(:epic, group: group) } let_it_be(:epic) { create(:epic, group: group) }
describe '.change_weight_note' do
it 'calls IssuableService' do
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
expect(service).to receive(:change_weight_note)
end
described_class.change_weight_note(noteable, project, author)
end
end
describe '.change_health_status_note' do describe '.change_health_status_note' do
it 'calls IssuableService' do it 'calls IssuableService' do
expect_next_instance_of(::SystemNotes::IssuablesService) do |service| expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
......
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