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

36 lines
839 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 }) {
2019-10-12 21:52:04 +05:30
const { startDate, projectIds } = options;
2018-11-08 19:23:39 +05:30
return this.axios
.get('', {
params: {
2019-10-12 21:52:04 +05:30
'cycle_analytics[start_date]': startDate,
'cycle_analytics[project_ids]': projectIds,
2018-11-08 19:23:39 +05:30
},
})
.then(x => x.data);
2017-08-17 22:00:37 +05:30
}
fetchStageData(options) {
2019-10-12 21:52:04 +05:30
const { stage, startDate, projectIds } = options;
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
return this.axios
.get(`events/${stage.name}.json`, {
params: {
'cycle_analytics[start_date]': startDate,
2019-10-12 21:52:04 +05:30
'cycle_analytics[project_ids]': projectIds,
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
}
}