Commit f63d1d6a authored by Luke Duncalfe's avatar Luke Duncalfe

Merge branch '329620-exclude-closed-items-vsa' into 'master'

Show only open items with "in progress" VSA

This change alters the `in_progress` filter in Value 
Stream Analytics. When the in progress filter is given, 
the backend will only query the Issue and Merge Request 
records which are in opened state.

The change is not user facing, the filter is not used 
on the UI yet.

See merge request gitlab-org/gitlab!61450
parents f29a27c7 642452f0
......@@ -359,7 +359,7 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::DataCollector do
let(:end_event_identifier) { :merge_request_merged }
def create_data_for_start_event(example_class)
create(:merge_request, :closed, source_project: example_class.project)
create(:merge_request, :unique_branches, :opened, source_project: example_class.project)
end
def create_data_for_end_event(mr, example_class)
......@@ -374,7 +374,7 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::DataCollector do
let(:end_event_identifier) { :merge_request_first_deployed_to_production }
def create_data_for_start_event(example_class)
create(:merge_request, :closed, source_project: example_class.project).tap do |mr|
create(:merge_request, :unique_branches, :opened, source_project: example_class.project).tap do |mr|
mr.metrics.update!(merged_at: Time.now)
end
end
......@@ -391,7 +391,7 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::DataCollector do
let(:end_event_identifier) { :merge_request_merged }
def create_data_for_start_event(example_class)
create(:merge_request, :merged, source_project: example_class.project).tap do |mr|
create(:merge_request, :unique_branches, :opened, source_project: example_class.project).tap do |mr|
mr.metrics.update!(first_commit_at: Time.now)
end
end
......@@ -408,7 +408,7 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::DataCollector do
let(:end_event_identifier) { :merge_request_last_build_finished }
def create_data_for_start_event(example_class)
create(:merge_request, :closed, source_project: example_class.project).tap do |mr|
create(:merge_request, :unique_branches, :opened, source_project: example_class.project).tap do |mr|
mr.metrics.update!(latest_build_started_at: Time.now)
end
end
......
......@@ -19,6 +19,7 @@ module Gitlab
def initialize(stage:, params: {})
@stage = stage
@params = build_finder_params(params)
@params[:state] = :opened if in_progress?
end
# rubocop: disable CodeReuse/ActiveRecord
......
......@@ -62,4 +62,29 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::BaseQueryBuilder do
expect(records.size).to eq(2)
end
describe 'in progress filter' do
let_it_be(:mr3) { create(:merge_request, :opened, target_project: project, source_project: project, allow_broken: true, created_at: 3.months.ago) }
let_it_be(:mr4) { create(:merge_request, :closed, target_project: project, source_project: project, allow_broken: true, created_at: 1.month.ago) }
before do
params[:from] = 5.months.ago
end
context 'when the filter is present' do
before do
params[:end_event_filter] = :in_progress
end
it 'returns only open items' do
expect(records).to eq([mr3])
end
end
context 'when the filter is absent' do
it 'returns finished items' do
expect(records).to match_array([mr1, mr2])
end
end
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