Commit 1db524a6 authored by Nathan Friend's avatar Nathan Friend

Merge branch 'jivanvl-remove-graphql-pipeline-analytics' into 'master'

Remove graphql_pipeline_analytics feature flag

See merge request gitlab-org/gitlab!51504
parents 8083c09e 1280db8f
<script>
import { GlTabs, GlTab } from '@gitlab/ui';
import PipelineCharts from './pipeline_charts.vue';
export default {
components: {
GlTabs,
GlTab,
PipelineCharts,
DeploymentFrequencyCharts: () =>
import('ee_component/projects/pipelines/charts/components/deployment_frequency_charts.vue'),
},
inject: {
shouldRenderDeploymentFrequencyCharts: {
type: Boolean,
default: false,
},
},
props: {
counts: {
type: Object,
required: true,
},
timesChartData: {
type: Object,
required: true,
},
lastWeekChartData: {
type: Object,
required: true,
},
lastMonthChartData: {
type: Object,
required: true,
},
lastYearChartData: {
type: Object,
required: true,
},
},
data() {
return {
// this loading flag gives the echarts library just enough time
// to ensure all DOM nodes have been mounted.
//
// https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1131
loading: true,
};
},
async mounted() {
await this.$nextTick();
this.loading = false;
},
};
</script>
<template>
<gl-tabs v-if="shouldRenderDeploymentFrequencyCharts">
<gl-tab :title="__('Pipelines')">
<pipeline-charts
:counts="counts"
:last-week="lastWeekChartData"
:last-month="lastMonthChartData"
:last-year="lastYearChartData"
:times-chart="timesChartData"
:loading="loading"
/>
</gl-tab>
<gl-tab :title="__('Deployments')">
<deployment-frequency-charts />
</gl-tab>
</gl-tabs>
<pipeline-charts
v-else
:counts="counts"
:last-week="lastWeekChartData"
:last-month="lastMonthChartData"
:last-year="lastYearChartData"
:times-chart="timesChartData"
/>
</template>
...@@ -2,7 +2,6 @@ import Vue from 'vue'; ...@@ -2,7 +2,6 @@ import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql'; import createDefaultClient from '~/lib/graphql';
import { parseBoolean } from '~/lib/utils/common_utils'; import { parseBoolean } from '~/lib/utils/common_utils';
import ProjectPipelinesChartsLegacy from './components/app_legacy.vue';
import ProjectPipelinesCharts from './components/app.vue'; import ProjectPipelinesCharts from './components/app.vue';
Vue.use(VueApollo); Vue.use(VueApollo);
...@@ -12,107 +11,24 @@ const apolloProvider = new VueApollo({ ...@@ -12,107 +11,24 @@ const apolloProvider = new VueApollo({
}); });
const mountPipelineChartsApp = (el) => { const mountPipelineChartsApp = (el) => {
// Not all of the values will be defined since some them will be const { projectPath } = el.dataset;
// empty depending on the value of the graphql_pipeline_analytics
// feature flag, once the rollout of the feature flag is completed
// the undefined values will be deleted
const {
countsFailed,
countsSuccess,
countsTotal,
countsTotalDuration,
successRatio,
timesChartLabels,
timesChartValues,
lastWeekChartLabels,
lastWeekChartTotals,
lastWeekChartSuccess,
lastMonthChartLabels,
lastMonthChartTotals,
lastMonthChartSuccess,
lastYearChartLabels,
lastYearChartTotals,
lastYearChartSuccess,
projectPath,
} = el.dataset;
const shouldRenderDeploymentFrequencyCharts = parseBoolean( const shouldRenderDeploymentFrequencyCharts = parseBoolean(
el.dataset.shouldRenderDeploymentFrequencyCharts, el.dataset.shouldRenderDeploymentFrequencyCharts,
); );
const parseAreaChartData = (labels, totals, success) => {
let parsedData = {};
try {
parsedData = {
labels: JSON.parse(labels),
totals: JSON.parse(totals),
success: JSON.parse(success),
};
} catch {
parsedData = {};
}
return parsedData;
};
if (gon?.features?.graphqlPipelineAnalytics) {
return new Vue({
el,
name: 'ProjectPipelinesChartsApp',
components: {
ProjectPipelinesCharts,
},
apolloProvider,
provide: {
projectPath,
shouldRenderDeploymentFrequencyCharts,
},
render: (createElement) => createElement(ProjectPipelinesCharts, {}),
});
}
return new Vue({ return new Vue({
el, el,
name: 'ProjectPipelinesChartsAppLegacy', name: 'ProjectPipelinesChartsApp',
components: { components: {
ProjectPipelinesChartsLegacy, ProjectPipelinesCharts,
}, },
apolloProvider,
provide: { provide: {
projectPath, projectPath,
shouldRenderDeploymentFrequencyCharts, shouldRenderDeploymentFrequencyCharts,
}, },
render: (createElement) => render: (createElement) => createElement(ProjectPipelinesCharts, {}),
createElement(ProjectPipelinesChartsLegacy, {
props: {
counts: {
failed: countsFailed,
success: countsSuccess,
total: countsTotal,
successRatio,
totalDuration: countsTotalDuration,
},
timesChartData: {
labels: JSON.parse(timesChartLabels),
values: JSON.parse(timesChartValues),
},
lastWeekChartData: parseAreaChartData(
lastWeekChartLabels,
lastWeekChartTotals,
lastWeekChartSuccess,
),
lastMonthChartData: parseAreaChartData(
lastMonthChartLabels,
lastMonthChartTotals,
lastMonthChartSuccess,
),
lastYearChartData: parseAreaChartData(
lastYearChartLabels,
lastYearChartTotals,
lastYearChartSuccess,
),
},
}),
}); });
}; };
......
...@@ -17,7 +17,6 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -17,7 +17,6 @@ class Projects::PipelinesController < Projects::ApplicationController
push_frontend_feature_flag(:new_pipeline_form, project, default_enabled: true) push_frontend_feature_flag(:new_pipeline_form, project, default_enabled: true)
push_frontend_feature_flag(:graphql_pipeline_header, project, type: :development, default_enabled: false) push_frontend_feature_flag(:graphql_pipeline_header, project, type: :development, default_enabled: false)
push_frontend_feature_flag(:graphql_pipeline_details, project, type: :development, default_enabled: false) push_frontend_feature_flag(:graphql_pipeline_details, project, type: :development, default_enabled: false)
push_frontend_feature_flag(:graphql_pipeline_analytics, project, type: :development)
push_frontend_feature_flag(:new_pipeline_form_prefilled_vars, project, type: :development, default_enabled: true) push_frontend_feature_flag(:new_pipeline_form_prefilled_vars, project, type: :development, default_enabled: true)
end end
before_action :ensure_pipeline, only: [:show] before_action :ensure_pipeline, only: [:show]
...@@ -189,23 +188,6 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -189,23 +188,6 @@ class Projects::PipelinesController < Projects::ApplicationController
end end
end end
def charts
@charts = {}
@counts = {}
return if Feature.enabled?(:graphql_pipeline_analytics)
@charts[:week] = Gitlab::Ci::Charts::WeekChart.new(project)
@charts[:month] = Gitlab::Ci::Charts::MonthChart.new(project)
@charts[:year] = Gitlab::Ci::Charts::YearChart.new(project)
@charts[:pipeline_times] = Gitlab::Ci::Charts::PipelineTime.new(project)
@counts[:total] = @project.all_pipelines.count(:all)
@counts[:success] = @project.all_pipelines.success.count(:all)
@counts[:failed] = @project.all_pipelines.failed.count(:all)
@counts[:total_duration] = @project.all_pipelines.total_duration
end
def test_report def test_report
respond_to do |format| respond_to do |format|
format.html do format.html do
......
- page_title _('CI / CD Analytics') - page_title _('CI / CD Analytics')
- if Feature.enabled?(:graphql_pipeline_analytics) #js-project-pipelines-charts-app{ data: { project_path: @project.full_path,
#js-project-pipelines-charts-app{ data: { project_path: @project.full_path, should_render_deployment_frequency_charts: should_render_deployment_frequency_charts.to_s } }
should_render_deployment_frequency_charts: should_render_deployment_frequency_charts.to_s } }
- else
#js-project-pipelines-charts-app{ data: { counts: @counts, success_ratio: success_ratio(@counts),
times_chart: { labels: @charts[:pipeline_times].labels, values: @charts[:pipeline_times].pipeline_times },
last_week_chart: { labels: @charts[:week].labels, totals: @charts[:week].total, success: @charts[:week].success },
last_month_chart: { labels: @charts[:month].labels, totals: @charts[:month].total, success: @charts[:month].success },
last_year_chart: { labels: @charts[:year].labels, totals: @charts[:year].total, success: @charts[:year].success },
project_path: @project.full_path,
should_render_deployment_frequency_charts: should_render_deployment_frequency_charts.to_s } }
---
title: Update pipeline graphs on CI/CD Analytics page to use GraphQL endpoint
merge_request: 51504
author:
type: changed
---
name: graphql_pipeline_analytics
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48267
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/290153
milestone: '13.7'
type: development
group: group::continuos integration
default_enabled: false
import { shallowMount } from '@vue/test-utils';
import Component from '~/projects/pipelines/charts/components/app_legacy.vue';
import PipelineCharts from '~/projects/pipelines/charts/components/pipeline_charts.vue';
import {
counts,
timesChartData,
areaChartData as lastWeekChartData,
areaChartData as lastMonthChartData,
lastYearChartData,
} from '../mock_data';
describe('ProjectsPipelinesChartsApp', () => {
let wrapper;
beforeEach(() => {
wrapper = shallowMount(Component, {
propsData: {
counts,
timesChartData,
lastWeekChartData,
lastMonthChartData,
lastYearChartData,
},
provide: {
projectPath: 'test/project',
shouldRenderDeploymentFrequencyCharts: true,
},
stubs: {
DeploymentFrequencyCharts: true,
},
});
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
describe('pipelines charts', () => {
it('displays the pipeline charts', () => {
const chart = wrapper.find(PipelineCharts);
expect(chart.exists()).toBe(true);
expect(chart.props()).toMatchObject({
counts,
lastWeek: lastWeekChartData,
lastMonth: lastMonthChartData,
lastYear: lastYearChartData,
timesChart: timesChartData,
});
});
});
});
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