Commit 6ab78ba7 authored by Stan Hu's avatar Stan Hu

Merge branch 'fix-any-label-queryin-vsa' into 'master'

Fix Any filter for labels in Value Stream Analytics

See merge request gitlab-org/gitlab!37584
parents c18f37e9 a131d5ff
---
title: Fix Any filter for labels in Value Stream Analytics
merge_request: 37584
author:
type: fixed
......@@ -544,6 +544,22 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::DataCollector do
it_behaves_like 'filter examples'
end
context 'when `Any` `label_name` is given' do
let(:label) { create(:group_label, group: group) }
before do
MergeRequests::UpdateService.new(
merge_request.project,
user,
label_ids: [label.id]
).execute(merge_request)
data_collector_params[:label_name] = ['Any']
end
it_behaves_like 'filter examples'
end
context 'when two labels are given' do
let(:label1) { create(:group_label, group: group) }
let(:label2) { create(:group_label, group: group) }
......
......@@ -82,7 +82,7 @@ module Gitlab
q = ordered_and_limited_query
.joins(ci_build_join)
.select(build_table[:id], round_duration_to_seconds.as('total_time'))
.select(build_table[:id], *time_columns)
results = execute_query(q).to_a
......@@ -95,7 +95,7 @@ module Gitlab
def records
results = ordered_and_limited_query
.select(*columns, round_duration_to_seconds.as('total_time'))
.select(*columns, *time_columns)
# using preloader instead of includes to avoid AR generating a large column list
ActiveRecord::Associations::Preloader.new.preload(
......@@ -106,6 +106,14 @@ module Gitlab
results
end
# rubocop: enable CodeReuse/ActiveRecord
def time_columns
[
stage.start_event.timestamp_projection.as('start_event_timestamp'),
stage.end_event.timestamp_projection.as('end_event_timestamp'),
round_duration_to_seconds.as('total_time')
]
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