Commit d6c03eb1 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Remove the in memory value stream when using the aggregated backend

This change removes returning an in-memory default value stream when no
value streams are present yet. This behavior will be used when the
aggregated VSA backend is enabled. The change is behind a feature flag.

Add `hasValueStreams` getter
parent 3dbb300d
This diff is collapsed.
......@@ -15,6 +15,7 @@ import { METRICS_REQUESTS } from '../constants';
import DurationChart from './duration_chart.vue';
import TypeOfWorkCharts from './type_of_work_charts.vue';
import ValueStreamAggregationStatus from './value_stream_aggregation_status.vue';
import ValueStreamEmptyState from './value_stream_empty_state.vue';
import ValueStreamSelect from './value_stream_select.vue';
export default {
......@@ -26,6 +27,7 @@ export default {
StageTable,
PathNavigation,
ValueStreamAggregationStatus,
ValueStreamEmptyState,
ValueStreamFilters,
ValueStreamMetrics,
ValueStreamSelect,
......@@ -74,9 +76,10 @@ export default {
'pathNavigationData',
'isOverviewStageSelected',
'selectedStageCount',
'hasValueStreams',
]),
shouldRenderEmptyState() {
return !this.currentGroup && !this.isLoading;
return !this.isLoadingValueStreams && !this.hasValueStreams;
},
shouldDisplayFilters() {
return !this.errorCode && !this.hasNoAccessError;
......@@ -198,24 +201,20 @@ export default {
</script>
<template>
<div>
<div
class="gl-mb-3 gl-display-flex gl-flex-direction-column gl-sm-flex-direction-row gl-justify-content-space-between"
>
<h3>{{ __('Value Stream Analytics') }}</h3>
<div class="gl-display-flex gl-flex-direction-row gl-align-items-center gl-mt-0 gl-sm-mt-5">
<value-stream-aggregation-status v-if="isAggregationStatusAvailable" :data="aggregation" />
<value-stream-select v-if="shouldDisplayCreateMultipleValueStreams" />
</div>
</div>
<gl-empty-state
<value-stream-empty-state
v-if="shouldRenderEmptyState"
:title="__('Value Stream Analytics can help you determine your team’s velocity')"
:description="
__('Filter parameters are not valid. Make sure that the end date is after the start date.')
"
:svg-path="emptyStateSvgPath"
:empty-state-svg-path="emptyStateSvgPath"
/>
<div v-else class="gl-max-w-full">
<div
class="gl-mb-3 gl-display-flex gl-flex-direction-column gl-sm-flex-direction-row gl-justify-content-space-between"
>
<h3>{{ __('Value Stream Analytics') }}</h3>
<div class="gl-display-flex gl-flex-direction-row gl-align-items-center gl-mt-0 gl-sm-mt-5">
<value-stream-aggregation-status v-if="isAggregationStatusAvailable" :data="aggregation" />
<value-stream-select v-if="shouldDisplayCreateMultipleValueStreams" />
</div>
</div>
<path-navigation
v-if="selectedStageReady"
data-testid="vsa-path-navigation"
......
......@@ -13,6 +13,8 @@ import { DEFAULT_VALUE_STREAM_ID, OVERVIEW_STAGE_CONFIG } from '../constants';
export const hasNoAccessError = (state) => state.errorCode === httpStatus.FORBIDDEN;
export const hasValueStreams = ({ valueStreams }) => Boolean(valueStreams?.length);
export const currentValueStreamId = ({ selectedValueStream }) =>
selectedValueStream?.id || DEFAULT_VALUE_STREAM_ID;
......
......@@ -97,7 +97,13 @@ class Groups::Analytics::CycleAnalytics::ValueStreamsController < Groups::Analyt
end
def value_streams
@group.value_streams.preload_associated_models.presence || [in_memory_default_value_stream]
value_streams = @group.value_streams.preload_associated_models
if Feature.enabled?(:use_vsa_aggregated_tables, @group, default_enabled: :yaml)
value_streams
else
value_streams.presence || [in_memory_default_value_stream]
end
end
def in_memory_default_value_stream
......
......@@ -16,14 +16,34 @@ RSpec.describe Groups::Analytics::CycleAnalytics::ValueStreamsController do
end
describe 'GET #index' do
it 'returns an in-memory default value stream' do
get :index, params: params
context 'when the use_vsa_aggregated_tables feature flag is off' do
before do
stub_feature_flags(use_vsa_aggregated_tables: false)
end
it 'returns an in-memory default value stream' do
get :index, params: params
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(1)
expect(json_response.first['id']).to eq(Analytics::CycleAnalytics::Stages::BaseService::DEFAULT_VALUE_STREAM_NAME)
expect(json_response.first['name']).to eq(Analytics::CycleAnalytics::Stages::BaseService::DEFAULT_VALUE_STREAM_NAME)
end
end
context 'when the use_vsa_aggregated_tables feature flag is on' do
before do
stub_feature_flags(use_vsa_aggregated_tables: true)
end
expect(response).to have_gitlab_http_status(:ok)
it 'returns an empty array' do
get :index, params: params
expect(json_response.size).to eq(1)
expect(json_response.first['id']).to eq(Analytics::CycleAnalytics::Stages::BaseService::DEFAULT_VALUE_STREAM_NAME)
expect(json_response.first['name']).to eq(Analytics::CycleAnalytics::Stages::BaseService::DEFAULT_VALUE_STREAM_NAME)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(0)
end
end
context 'when persisted value streams present' do
......
......@@ -25,6 +25,7 @@ RSpec.describe 'Multiple value streams', :js do
end
before do
stub_feature_flags(use_vsa_aggregated_tables: false)
stub_licensed_features(cycle_analytics_for_groups: true, type_of_work_analytics: true)
sign_in(user)
......
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