Commit 718e32ca authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'remove-upsert-issue-metrics-feature-flag' into 'master'

Remove upsert_issue_metrics feature flag

See merge request gitlab-org/gitlab!68829
parents ab863e88 2e627c8b
......@@ -586,14 +586,7 @@ class Issue < ApplicationRecord
override :ensure_metrics
def ensure_metrics
return Issue::Metrics.record!(self) if Feature.enabled?(:upsert_issue_metrics, default_enabled: :yaml)
if !association(:metrics).loaded? || metrics.blank?
metrics_record = Issue::Metrics.safe_find_or_create_by(issue: self)
self.metrics = metrics_record
end
metrics.record!
Issue::Metrics.record!(self)
end
def record_create_action
......
......@@ -35,22 +35,4 @@ class Issue::Metrics < ApplicationRecord
issue.labels.joins(:lists).exists?
end
end
def record!
if issue.milestone_id.present? && self.first_associated_with_milestone_at.blank?
self.first_associated_with_milestone_at = Time.current
end
if issue_assigned_to_list_label? && self.first_added_to_board_at.blank?
self.first_added_to_board_at = Time.current
end
self.save
end
private
def issue_assigned_to_list_label?
issue.labels.joins(:lists).exists?
end
end
---
name: upsert_issue_metrics
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68509
rollout_issue_url:
milestone: '14.3'
type: development
group: group::project management
default_enabled: false
......@@ -34,7 +34,7 @@ RSpec.describe Issue::Metrics do
end
end
shared_examples "when recording the default set of issue metrics on issue save" do
context "when recording the default set of issue metrics on issue save" do
context "milestones" do
it "records the first time an issue is associated with a milestone" do
time = Time.current
......@@ -81,20 +81,4 @@ RSpec.describe Issue::Metrics do
end
end
end
context 'when upsert_issue_metrics is enabled' do
before do
stub_feature_flags(upsert_issue_metrics: true)
end
it_behaves_like 'when recording the default set of issue metrics on issue save'
end
context 'when upsert_issue_metrics is disabled' do
before do
stub_feature_flags(upsert_issue_metrics: false)
end
it_behaves_like 'when recording the default set of issue metrics on issue save'
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