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

42 lines
879 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
const global = window.gl || (window.gl = {});
global.cycleAnalytics = global.cycleAnalytics || {};
2016-10-20 04:34:16 +00:00
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: {
start_date: options.startDate,
2016-11-19 00:38:29 +00:00
},
},
});
}
fetchStageData(options) {
const {
stage,
startDate,
} = options;
return $.get(`${this.requestPath}/events/${stage.name}.json`, {
cycle_analytics: {
start_date: startDate,
},
});
2016-11-19 00:38:29 +00:00
}
}
2016-10-20 04:34:16 +00:00
global.cycleAnalytics.CycleAnalyticsService = CycleAnalyticsService;