1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-12-10 21:48:03 -05:00
shimapan/app/public/services/StatSvc.js

49 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2018-12-31 18:37:34 -05:00
const angular = require('angular');
2018-09-15 18:25:07 -04:00
angular.module('StatSvc', []).service('StatService', ['$http', function($http) {
2019-01-01 17:55:04 -05:00
this.getUploads = async () => {
2018-12-31 18:37:34 -05:00
const res = await $http({
2018-09-15 18:25:07 -04:00
method: 'GET',
2019-01-01 17:55:04 -05:00
url: '/api/stats/uploads'
2018-09-15 18:25:07 -04:00
});
2018-12-31 18:37:34 -05:00
return res.data;
};
2019-01-01 17:55:04 -05:00
this.getUploadsWeek = async () => {
let oneWeekAgo = new Date();
oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);
2018-12-31 18:37:34 -05:00
const res = await $http({
2018-09-15 18:25:07 -04:00
method: 'GET',
2019-01-01 17:55:04 -05:00
url: '/api/stats/uploads',
data: {
after: oneWeekAgo
}
2018-09-15 18:25:07 -04:00
});
2018-12-31 18:37:34 -05:00
return res.data;
2019-01-01 17:55:04 -05:00
};
this.getViews = async () => {
const res = await $http({
method: 'GET',
url: '/api/stats/views'
});
return res.data;
};
this.getViewsWeek = async () => {
let oneWeekAgo = new Date();
oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);
const res = await $http({
method: 'GET',
url: '/api/stats/uploads'
});
return res.data;
};
2018-09-15 18:25:07 -04:00
}]);