debian-mirror-gitlab/app/assets/javascripts/cycle_analytics/cycle_analytics_service.js

35 lines
696 B
JavaScript
Raw Normal View History

2018-11-08 19:23:39 +05:30
import axios from '~/lib/utils/axios_utils';
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
export default class CycleAnalyticsService {
2017-08-17 22:00:37 +05:30
constructor(options) {
2018-11-08 19:23:39 +05:30
this.axios = axios.create({
baseURL: options.requestPath,
});
2017-08-17 22:00:37 +05:30
}
2018-03-17 18:26:18 +05:30
fetchCycleAnalyticsData(options = { startDate: 30 }) {
2018-11-08 19:23:39 +05:30
return this.axios
.get('', {
params: {
'cycle_analytics[start_date]': options.startDate,
},
})
.then(x => x.data);
2017-08-17 22:00:37 +05:30
}
fetchStageData(options) {
const {
stage,
startDate,
} = options;
2018-11-08 19:23:39 +05:30
return this.axios
.get(`events/${stage.name}.json`, {
params: {
'cycle_analytics[start_date]': startDate,
2018-03-17 18:26:18 +05:30
},
2018-11-08 19:23:39 +05:30
})
.then(x => x.data);
2017-08-17 22:00:37 +05:30
}
}