Commit 8710f533 authored by Martin Wortschack's avatar Martin Wortschack

Add new members count

- Adds the number of new members
to the group activity analytics
panel.
parent 68110a08
...@@ -21,6 +21,7 @@ export default { ...@@ -21,6 +21,7 @@ export default {
metrics: { metrics: {
mergeRequests: { value: null, label: s__('GroupActivyMetrics|Merge Requests created') }, mergeRequests: { value: null, label: s__('GroupActivyMetrics|Merge Requests created') },
issues: { value: null, label: s__('GroupActivyMetrics|Issues created') }, issues: { value: null, label: s__('GroupActivyMetrics|Issues created') },
newMembers: { value: null, label: s__('GroupActivityMetrics|New Members created') },
}, },
}; };
}, },
...@@ -46,10 +47,12 @@ export default { ...@@ -46,10 +47,12 @@ export default {
return Promise.all([ return Promise.all([
Api.groupActivityMergeRequestsCount(groupPath), Api.groupActivityMergeRequestsCount(groupPath),
Api.groupActivityIssuesCount(groupPath), Api.groupActivityIssuesCount(groupPath),
Api.groupActivityNewMembersCount(groupPath),
]) ])
.then(([mrResponse, issuesResponse]) => { .then(([mrResponse, issuesResponse, newMembersResponse]) => {
this.metrics.mergeRequests.value = mrResponse.data.merge_requests_count; this.metrics.mergeRequests.value = mrResponse.data.merge_requests_count;
this.metrics.issues.value = issuesResponse.data.issues_count; this.metrics.issues.value = issuesResponse.data.issues_count;
this.metrics.newMembers.value = newMembersResponse.data.new_members_count;
this.isLoading = false; this.isLoading = false;
}) })
.catch(() => { .catch(() => {
......
...@@ -28,6 +28,7 @@ export default { ...@@ -28,6 +28,7 @@ export default {
codeReviewAnalyticsPath: '/api/:version/analytics/code_review', codeReviewAnalyticsPath: '/api/:version/analytics/code_review',
groupActivityIssuesPath: '/api/:version/analytics/group_activity/issues_count', groupActivityIssuesPath: '/api/:version/analytics/group_activity/issues_count',
groupActivityMergeRequestsPath: '/api/:version/analytics/group_activity/merge_requests_count', groupActivityMergeRequestsPath: '/api/:version/analytics/group_activity/merge_requests_count',
groupActivityNewMembersPath: '/api/:version/analytics/group_activity/new_members_count',
countriesPath: '/-/countries', countriesPath: '/-/countries',
countryStatesPath: '/-/country_states', countryStatesPath: '/-/country_states',
paymentFormPath: '/-/subscriptions/payment_form', paymentFormPath: '/-/subscriptions/payment_form',
...@@ -235,6 +236,11 @@ export default { ...@@ -235,6 +236,11 @@ export default {
return axios.get(url, { params: { group_path: groupPath } }); return axios.get(url, { params: { group_path: groupPath } });
}, },
groupActivityNewMembersCount(groupPath) {
const url = Api.buildUrl(this.groupActivityNewMembersPath);
return axios.get(url, { params: { group_path: groupPath } });
},
getGeoReplicableItems(replicable, params = {}) { getGeoReplicableItems(replicable, params = {}) {
const url = Api.buildUrl(this.geoReplicationPath).replace(':replicable', replicable); const url = Api.buildUrl(this.geoReplicationPath).replace(':replicable', replicable);
return axios.get(url, { params }); return axios.get(url, { params });
......
...@@ -51,6 +51,21 @@ exports[`GroupActivity component matches the snapshot 1`] = ` ...@@ -51,6 +51,21 @@ exports[`GroupActivity component matches the snapshot 1`] = `
Issues created Issues created
</p> </p>
</div> </div>
<div
class="flex-grow text-center"
>
<h3
class="my-2"
>
30
</h3>
<p
class="text-secondary gl-font-size-small mb-2"
>
New Members created
</p>
</div>
</div> </div>
</div> </div>
......
...@@ -9,6 +9,7 @@ import waitForPromises from 'helpers/wait_for_promises'; ...@@ -9,6 +9,7 @@ import waitForPromises from 'helpers/wait_for_promises';
const TEST_GROUP_ID = 'gitlab-org'; const TEST_GROUP_ID = 'gitlab-org';
const TEST_MERGE_REQUESTS_COUNT = { data: { merge_requests_count: 10 } }; const TEST_MERGE_REQUESTS_COUNT = { data: { merge_requests_count: 10 } };
const TEST_ISSUES_COUNT = { data: { issues_count: 20 } }; const TEST_ISSUES_COUNT = { data: { issues_count: 20 } };
const TEST_NEW_MEMBERS_COUNT = { data: { new_members_count: 30 } };
describe('GroupActivity component', () => { describe('GroupActivity component', () => {
let wrapper; let wrapper;
...@@ -30,6 +31,10 @@ describe('GroupActivity component', () => { ...@@ -30,6 +31,10 @@ describe('GroupActivity component', () => {
.mockReturnValue(Promise.resolve(TEST_MERGE_REQUESTS_COUNT)); .mockReturnValue(Promise.resolve(TEST_MERGE_REQUESTS_COUNT));
jest.spyOn(Api, 'groupActivityIssuesCount').mockReturnValue(Promise.resolve(TEST_ISSUES_COUNT)); jest.spyOn(Api, 'groupActivityIssuesCount').mockReturnValue(Promise.resolve(TEST_ISSUES_COUNT));
jest
.spyOn(Api, 'groupActivityNewMembersCount')
.mockReturnValue(Promise.resolve(TEST_NEW_MEMBERS_COUNT));
}); });
afterEach(() => { afterEach(() => {
...@@ -60,6 +65,7 @@ describe('GroupActivity component', () => { ...@@ -60,6 +65,7 @@ describe('GroupActivity component', () => {
.then(() => { .then(() => {
expect(Api.groupActivityMergeRequestsCount).toHaveBeenCalledWith(TEST_GROUP_ID); expect(Api.groupActivityMergeRequestsCount).toHaveBeenCalledWith(TEST_GROUP_ID);
expect(Api.groupActivityIssuesCount).toHaveBeenCalledWith(TEST_GROUP_ID); expect(Api.groupActivityIssuesCount).toHaveBeenCalledWith(TEST_GROUP_ID);
expect(Api.groupActivityNewMembersCount).toHaveBeenCalledWith(TEST_GROUP_ID);
waitForPromises(); waitForPromises();
}) })
...@@ -67,6 +73,7 @@ describe('GroupActivity component', () => { ...@@ -67,6 +73,7 @@ describe('GroupActivity component', () => {
expect(wrapper.vm.isLoading).toBe(false); expect(wrapper.vm.isLoading).toBe(false);
expect(wrapper.vm.metrics.mergeRequests.value).toBe(10); expect(wrapper.vm.metrics.mergeRequests.value).toBe(10);
expect(wrapper.vm.metrics.issues.value).toBe(20); expect(wrapper.vm.metrics.issues.value).toBe(20);
expect(wrapper.vm.metrics.newMembers.value).toBe(30);
}); });
}); });
...@@ -80,6 +87,7 @@ describe('GroupActivity component', () => { ...@@ -80,6 +87,7 @@ describe('GroupActivity component', () => {
expect(findMetricCard().props('metrics')).toEqual([ expect(findMetricCard().props('metrics')).toEqual([
{ key: 'mergeRequests', value: 10, label: 'Merge Requests created' }, { key: 'mergeRequests', value: 10, label: 'Merge Requests created' },
{ key: 'issues', value: 20, label: 'Issues created' }, { key: 'issues', value: 20, label: 'Issues created' },
{ key: 'newMembers', value: 30, label: 'New Members created' },
]); ]);
}); });
}); });
......
...@@ -583,6 +583,22 @@ describe('Api', () => { ...@@ -583,6 +583,22 @@ describe('Api', () => {
}); });
}); });
}); });
describe('groupActivityNewMembersCount', () => {
it('fetches the number of new members created for a given group', () => {
const response = { new_members_count: 30 };
const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/analytics/group_activity/new_members_count`;
jest.spyOn(Api, 'buildUrl').mockReturnValue(expectedUrl);
jest.spyOn(axios, 'get');
mock.onGet(expectedUrl).reply(200, response);
return Api.groupActivityNewMembersCount(groupId).then(({ data }) => {
expect(data).toEqual(response);
expect(axios.get).toHaveBeenCalledWith(expectedUrl, { params: { group_path: groupId } });
});
});
});
}); });
describe('GeoReplicable', () => { describe('GeoReplicable', () => {
......
...@@ -10145,6 +10145,9 @@ msgstr "" ...@@ -10145,6 +10145,9 @@ msgstr ""
msgid "Group: %{name}" msgid "Group: %{name}"
msgstr "" msgstr ""
msgid "GroupActivityMetrics|New Members created"
msgstr ""
msgid "GroupActivyMetrics|Issues created" msgid "GroupActivyMetrics|Issues created"
msgstr "" msgstr ""
......
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