gitlab-org--gitlab-foss/app/assets/javascripts/cycle_analytics/cycle_analytics_service.js

42 lines
961 B
JavaScript
Raw Normal View History

2016-11-19 00:38:29 +00:00
/* eslint-disable no-param-reassign */
2016-10-20 04:34:16 +00:00
((global) => {
global.cycleAnalytics = global.cycleAnalytics || {};
class CycleAnalyticsService {
constructor(options) {
this.requestPath = options.requestPath;
}
fetchCycleAnalyticsData(options) {
options = options || { startDate: 30 };
return $.ajax({
url: this.requestPath,
method: 'GET',
dataType: 'json',
contentType: 'application/json',
data: {
cycle_analytics: {
2016-11-19 00:38:29 +00:00
start_date: options.startDate,
},
},
2016-10-20 04:34:16 +00:00
});
}
fetchStageData(options) {
2016-11-19 00:38:29 +00:00
const {
stage,
startDate,
} = options;
2016-11-18 19:32:06 +00:00
return $.get(`${this.requestPath}/events/${stage.title.toLowerCase()}.json`, {
cycle_analytics: {
2016-11-19 00:38:29 +00:00
start_date: startDate,
},
});
}
2016-11-19 00:38:29 +00:00
}
2016-10-20 04:34:16 +00:00
global.cycleAnalytics.CycleAnalyticsService = CycleAnalyticsService;
})(window.gl || (window.gl = {}));