Skip to content
代码片段 群组 项目
提交 51585a32 编辑于 作者: Rudy Crespo's avatar Rudy Crespo 提交者: Himanshu Kapoor
浏览文件

Provide legacy page data if feature flag disabled

As part of the conversion to GraphQL, legacy page data will only be
passed down to app if the contribution-analytics-graphql feature flag
is disabled.

EE: true
上级 f5212e35
No related branches found
No related tags found
无相关合并请求
import Vue from 'vue'; import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import * as Sentry from '@sentry/browser';
import createDefaultClient from '~/lib/graphql'; import createDefaultClient from '~/lib/graphql';
import LegacyApp from './legacy_components/app.vue'; import LegacyApp from './legacy_components/app.vue';
import App from './components/app.vue'; import App from './components/app.vue';
...@@ -27,12 +28,22 @@ export default (el) => { ...@@ -27,12 +28,22 @@ export default (el) => {
memberContributionsPath, memberContributionsPath,
} = el.dataset; } = el.dataset;
let analyticsDataParsed = {};
if (!gon.features?.contributionAnalyticsGraphql) {
try {
analyticsDataParsed = JSON.parse(analyticsData);
} catch (e) {
Sentry.captureException(e);
}
}
const { const {
labels, labels,
push, push,
merge_requests_created: mergeRequestsCreated, merge_requests_created: mergeRequestsCreated,
issues_closed: issuesClosed, issues_closed: issuesClosed,
} = JSON.parse(analyticsData); } = analyticsDataParsed;
return new Vue({ return new Vue({
el, el,
......
...@@ -14,15 +14,6 @@ ...@@ -14,15 +14,6 @@
start_date: @start_date.to_date.iso8601, start_date: @start_date.to_date.iso8601,
end_date: Date.today.iso8601, end_date: Date.today.iso8601,
analytics_data: @data_collector.group_member_contributions_table_data.to_json.html_safe, **@data_collector.legacy_page_data
total_push_count: @data_collector.total_push_count,
total_commit_count: @data_collector.total_commit_count,
total_push_author_count: @data_collector.total_push_author_count,
total_merge_requests_closed_count: @data_collector.total_merge_requests_closed_count,
total_merge_requests_created_count: @data_collector.total_merge_requests_created_count,
total_merge_requests_merged_count: @data_collector.total_merge_requests_merged_count,
total_issues_created_count: @data_collector.total_issues_created_count,
total_issues_closed_count: @data_collector.total_issues_closed_count,
member_contributions_path: group_contribution_analytics_path(@group, { start_date: @start_date, format: :json })
} }
} }
...@@ -130,6 +130,23 @@ def totals ...@@ -130,6 +130,23 @@ def totals
} }
end end
def legacy_page_data
return {} if Feature.enabled?(:contribution_analytics_graphql, group)
{
analytics_data: group_member_contributions_table_data.to_json.html_safe,
total_push_count: total_push_count,
total_commit_count: total_commit_count,
total_push_author_count: total_push_author_count,
total_merge_requests_closed_count: total_merge_requests_closed_count,
total_merge_requests_created_count: total_merge_requests_created_count,
total_merge_requests_merged_count: total_merge_requests_merged_count,
total_issues_created_count: total_issues_created_count,
total_issues_closed_count: total_issues_closed_count,
member_contributions_path: ::Gitlab::Routing.url_helpers.group_contribution_analytics_path(group, { start_date: from, format: :json })
}
end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def base_query def base_query
cte = Gitlab::SQL::CTE.new(:project_ids, cte = Gitlab::SQL::CTE.new(:project_ids,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Gitlab::ContributionAnalytics::DataCollector do RSpec.describe Gitlab::ContributionAnalytics::DataCollector, feature_category: :value_stream_management do
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:project1) { create(:project, group: group) } let_it_be(:project1) { create(:project, group: group) }
let_it_be(:project2) { create(:project, group: group) } let_it_be(:project2) { create(:project, group: group) }
...@@ -136,4 +136,37 @@ ...@@ -136,4 +136,37 @@
end end
end end
end end
describe '#legacy_page_data' do
subject { described_class.new(group: group).legacy_page_data }
context 'when contribution_analytics_graphql feature flag is enabled' do
before do
stub_feature_flags(contribution_analytics_graphql: true)
end
it { is_expected.to eq({}) }
end
context 'when contribution_analytics_graphql feature flag is not enabled' do
before do
stub_feature_flags(contribution_analytics_graphql: false)
end
it {
is_expected.to include(
:analytics_data,
:total_push_count,
:total_commit_count,
:total_push_author_count,
:total_merge_requests_closed_count,
:total_merge_requests_created_count,
:total_merge_requests_merged_count,
:total_issues_created_count,
:total_issues_closed_count,
:member_contributions_path
)
}
end
end
end end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册