2018-05-09 17:21:06 -04:00
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2016-10-20 00:34:16 -04:00
|
|
|
|
2017-09-25 07:23:29 -04:00
|
|
|
export default class CycleAnalyticsService {
|
2017-04-10 21:02:55 -04:00
|
|
|
constructor(options) {
|
2018-05-09 17:21:06 -04:00
|
|
|
this.axios = axios.create({
|
|
|
|
baseURL: options.requestPath,
|
|
|
|
});
|
2017-04-10 21:02:55 -04:00
|
|
|
}
|
2016-10-20 19:24:36 -04:00
|
|
|
|
2017-09-25 07:23:29 -04:00
|
|
|
fetchCycleAnalyticsData(options = { startDate: 30 }) {
|
2019-07-24 09:59:23 -04:00
|
|
|
const { startDate, projectIds } = options;
|
|
|
|
|
2018-05-09 17:21:06 -04:00
|
|
|
return this.axios
|
|
|
|
.get('', {
|
|
|
|
params: {
|
2019-07-24 09:59:23 -04:00
|
|
|
'cycle_analytics[start_date]': startDate,
|
|
|
|
'cycle_analytics[project_ids]': projectIds,
|
2018-05-09 17:21:06 -04:00
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(x => x.data);
|
2017-04-10 21:02:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fetchStageData(options) {
|
2019-07-24 09:59:23 -04:00
|
|
|
const { stage, startDate, projectIds } = options;
|
2017-04-10 21:02:55 -04:00
|
|
|
|
2018-05-09 17:21:06 -04:00
|
|
|
return this.axios
|
|
|
|
.get(`events/${stage.name}.json`, {
|
|
|
|
params: {
|
|
|
|
'cycle_analytics[start_date]': startDate,
|
2019-07-24 09:59:23 -04:00
|
|
|
'cycle_analytics[project_ids]': projectIds,
|
2017-09-25 07:23:29 -04:00
|
|
|
},
|
2018-05-09 17:21:06 -04:00
|
|
|
})
|
|
|
|
.then(x => x.data);
|
2016-11-18 19:38:29 -05:00
|
|
|
}
|
2017-04-10 21:02:55 -04:00
|
|
|
}
|