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

42 lines
961 B
JavaScript
Raw Normal View History

2016-11-18 19:38:29 -05:00
/* eslint-disable no-param-reassign */
2016-10-20 00:34:16 -04: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-18 19:38:29 -05:00
start_date: options.startDate,
},
},
2016-10-20 00:34:16 -04:00
});
}
fetchStageData(options) {
2016-11-18 19:38:29 -05:00
const {
stage,
startDate,
} = options;
2016-11-18 14:32:06 -05:00
return $.get(`${this.requestPath}/events/${stage.title.toLowerCase()}.json`, {
cycle_analytics: {
2016-11-18 19:38:29 -05:00
start_date: startDate,
},
});
}
2016-11-18 19:38:29 -05:00
}
2016-10-20 00:34:16 -04:00
global.cycleAnalytics.CycleAnalyticsService = CycleAnalyticsService;
})(window.gl || (window.gl = {}));