Commit 980fa2b3 authored by Brandon Labuschagne's avatar Brandon Labuschagne Committed by Phil Hughes

Add CA duration chart endpoint

parent ab3c3fed
......@@ -23,6 +23,7 @@ export default {
cycleAnalyticsGroupStagesAndEventsPath: '/-/analytics/cycle_analytics/stages',
cycleAnalyticsStageEventsPath: '/groups/:group_id/-/cycle_analytics/events/:stage_id.json',
cycleAnalyticsStagePath: '/-/analytics/cycle_analytics/stages/:stage_id',
cycleAnalyticsDurationChartPath: '/-/analytics/cycle_analytics/stages/:stage_id/duration_chart',
userSubscription(namespaceId) {
const url = Api.buildUrl(this.subscriptionPath).replace(':id', encodeURIComponent(namespaceId));
......@@ -154,6 +155,7 @@ export default {
cycleAnalyticsGroupStagesAndEvents(groupId, params = {}) {
const url = Api.buildUrl(this.cycleAnalyticsGroupStagesAndEventsPath);
return axios.get(url, {
params: { group_id: groupId, ...params },
});
......@@ -194,4 +196,12 @@ export default {
params: { group_id: groupId },
});
},
cycleAnalyticsDurationChart(stageSlug, params = {}) {
const url = Api.buildUrl(this.cycleAnalyticsDurationChartPath).replace(':stage_id', stageSlug);
return axios.get(url, {
params,
});
},
};
......@@ -477,5 +477,29 @@ describe('Api', () => {
.catch(done.fail);
});
});
describe('cycleAnalyticsDurationChart', () => {
it('fetches stage duration data', done => {
const response = [];
const params = {
group_id: groupId,
created_after: createdAfter,
created_before: createdBefore,
};
const expectedUrl = `${dummyUrlRoot}/-/analytics/cycle_analytics/stages/thursday/duration_chart`;
mock.onGet(expectedUrl).reply(200, response);
Api.cycleAnalyticsDurationChart(stageId, params)
.then(responseObj =>
expectRequestWithCorrectParameters(responseObj, {
response,
params,
expectedUrl,
}),
)
.then(done)
.catch(done.fail);
});
});
});
});
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