Commit a0afbe1d authored by Markus Koller's avatar Markus Koller

Merge branch '328219-remove-unused-vsa-methods' into 'master'

Remove duration_chart endpoint

See merge request gitlab-org/gitlab!61989
parents 54edee77 8a5ddea1
......@@ -9,8 +9,8 @@ module Groups
before_action :load_group
before_action :load_value_stream
before_action :validate_params, only: %i[median average records duration_chart average_duration_chart count]
before_action :authorize_read_group_stage, only: %i[median average records duration_chart average_duration_chart count]
before_action :validate_params, only: %i[median average records average_duration_chart count]
before_action :authorize_read_group_stage, only: %i[median average records average_duration_chart count]
def index
return render_403 unless can?(current_user, :read_group_cycle_analytics, @group)
......@@ -58,10 +58,6 @@ module Groups
render json: serialized_records
end
def duration_chart
render json: ::Analytics::CycleAnalytics::DurationChartItemEntity.represent(data_collector.duration_chart_data)
end
def average_duration_chart
render json: ::Analytics::CycleAnalytics::DurationChartAverageItemEntity.represent(data_collector.duration_chart_average_data)
end
......
......@@ -28,7 +28,6 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
resources :stages, only: [:index, :create, :update, :destroy] do
member do
get :average_duration_chart
get :duration_chart
get :median
get :average
get :records
......@@ -39,7 +38,6 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
resources :stages, only: [:index, :create, :update, :destroy] do
member do
get :average_duration_chart
get :duration_chart
get :median
get :average
get :records
......
......@@ -5,13 +5,6 @@ module EE
module Analytics
module CycleAnalytics
module DataCollector
# Deprecated, will be removed in the next milestone: https://gitlab.com/gitlab-org/gitlab/-/issues/328219
def duration_chart_data
strong_memoize(:duration_chart) do
duration_chart.load
end
end
def duration_chart_average_data
strong_memoize(:duration_chart_average_data) do
duration_chart.average_by_day
......
......@@ -14,14 +14,6 @@ module Gitlab
@query = query
end
# rubocop: disable CodeReuse/ActiveRecord
def load
order_by(query, :end_event, :desc)
.select(round_duration_to_seconds.as('duration_in_seconds'), stage.end_event.timestamp_projection.as('finished_at'))
.limit(MAX_RESULTS)
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def average_by_day
date = Arel::Nodes::NamedFunction.new('DATE', [stage.end_event.timestamp_projection])
......
{
"type": "array",
"items": {
"type": "object",
"required": ["duration_in_seconds", "finished_at"],
"properties": {
"duration_in_seconds": {
"type": "integer"
},
"finished_at": {
"type": "string"
}
},
"additionalProperties": false
}
}
......@@ -104,16 +104,6 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::DataCollector do
expect(round_to_days(data_collector.median.seconds)).to eq(10)
end
describe '#duration_chart_data' do
subject { data_collector.duration_chart_data }
it 'loads data ordered by event time' do
days = subject.map { |item| round_to_days(item.duration_in_seconds) }
expect(days).to eq([15, 10, 5])
end
end
describe '#duration_chart_average_data' do
subject { data_collector.duration_chart_average_data }
......
......@@ -251,23 +251,7 @@ RSpec.shared_examples 'Value Stream Analytics Stages controller' do
end
end
describe 'GET #duration_chart' do
subject { get :duration_chart, params: params }
it 'matches the response schema' do
fake_result = [double(MergeRequest, duration_in_seconds: 10, finished_at: Time.current)]
expect_any_instance_of(Gitlab::Analytics::CycleAnalytics::DataForDurationChart).to receive(:load).and_return(fake_result)
subject
expect(response).to match_response_schema('analytics/cycle_analytics/duration_chart', dir: 'ee')
end
include_examples 'Value Stream Analytics data endpoint examples'
include_examples 'group permission check on the controller level'
end
describe 'GET #duration_chart' do
describe 'GET #average_duration_chart' do
subject { get :average_duration_chart, params: params }
it 'matches the response schema' do
......
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