Commit 6740701a authored by Adam Hegyi's avatar Adam Hegyi Committed by Nikola Milojevic

Fix VSA FF scope to groups

parent dd93b837
......@@ -4,6 +4,7 @@ module Groups
module Analytics
module CycleAnalytics
class SummaryController < Groups::Analytics::ApplicationController
extend ::Gitlab::Utils::Override
include CycleAnalyticsParams
before_action :load_group
......@@ -27,6 +28,11 @@ module Groups
def authorize_access
return render_403 unless can?(current_user, :read_group_cycle_analytics, @group)
end
override :all_cycle_analytics_params
def all_cycle_analytics_params
super.merge({ group: @group })
end
end
end
end
......
......@@ -19,6 +19,8 @@ module Analytics
@cursor = cursor
@updated_at_before = updated_at_before
@upsert_count = 0
load_stages # ensure stages are loaded/created
end
def execute
......@@ -54,7 +56,7 @@ module Analytics
private
attr_reader :group, :model, :cursor, :updated_at_before, :upsert_count
attr_reader :group, :model, :cursor, :updated_at_before, :upsert_count, :stages
def error(error_reason)
ServiceResponse.error(
......@@ -172,8 +174,8 @@ module Analytics
"column_" + event.hash_code[0...10]
end
def stages
@stages ||= Gitlab::Analytics::CycleAnalytics::DistinctStageLoader
def load_stages
@stages ||= ::Gitlab::Analytics::CycleAnalytics::DistinctStageLoader
.new(group: group)
.stages
.select { |stage| stage.start_event.object_type == model }
......
......@@ -48,5 +48,25 @@ RSpec.describe Groups::Analytics::CycleAnalytics::SummaryController do
subject { get :time_summary, params: params }
it_behaves_like 'summary endpoint'
it 'passes the group to RequestParams' do
expect_next_instance_of(Gitlab::Analytics::CycleAnalytics::RequestParams) do |instance|
expect(instance.group).to eq(group)
end
subject
end
it 'uses the aggregated VSA data collector' do
# Ensure stage_hash_id is present for Lead Time and CycleTime
Analytics::CycleAnalytics::DataLoaderService.new(group: group, model: Issue).execute
# Calculating Cycle Time and Lead Time
expect(Gitlab::Analytics::CycleAnalytics::Aggregated::DataCollector).to receive(:new).twice.and_call_original
subject
expect(response).to be_successful
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