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

31 lines
691 B
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import Vue from 'vue';
import VueResource from 'vue-resource';
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
Vue.use(VueResource);
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) {
this.requestPath = options.requestPath;
2018-03-17 18:26:18 +05:30
this.cycleAnalytics = Vue.resource(this.requestPath);
2017-08-17 22:00:37 +05:30
}
2018-03-17 18:26:18 +05:30
fetchCycleAnalyticsData(options = { startDate: 30 }) {
return this.cycleAnalytics.get({ cycle_analytics: { start_date: options.startDate } });
2017-08-17 22:00:37 +05:30
}
fetchStageData(options) {
const {
stage,
startDate,
} = options;
2018-03-17 18:26:18 +05:30
return Vue.http.get(`${this.requestPath}/events/${stage.name}.json`, {
params: {
cycle_analytics: {
start_date: startDate,
},
2017-08-17 22:00:37 +05:30
},
});
}
}