Commit a131d5ff authored by Adam Hegyi's avatar Adam Hegyi

Fix InvalidColumnReference error in VSA

parent 70039994
---
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 ...@@ -544,6 +544,22 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::DataCollector do
it_behaves_like 'filter examples' it_behaves_like 'filter examples'
end 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 context 'when two labels are given' do
let(:label1) { create(:group_label, group: group) } let(:label1) { create(:group_label, group: group) }
let(:label2) { create(:group_label, group: group) } let(:label2) { create(:group_label, group: group) }
......
...@@ -82,7 +82,7 @@ module Gitlab ...@@ -82,7 +82,7 @@ module Gitlab
q = ordered_and_limited_query q = ordered_and_limited_query
.joins(ci_build_join) .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 results = execute_query(q).to_a
...@@ -95,7 +95,7 @@ module Gitlab ...@@ -95,7 +95,7 @@ module Gitlab
def records def records
results = ordered_and_limited_query 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 # using preloader instead of includes to avoid AR generating a large column list
ActiveRecord::Associations::Preloader.new.preload( ActiveRecord::Associations::Preloader.new.preload(
...@@ -106,6 +106,14 @@ module Gitlab ...@@ -106,6 +106,14 @@ module Gitlab
results results
end end
# rubocop: enable CodeReuse/ActiveRecord # 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 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