1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-12-04 19:32:20 -05:00
shimapan/app/public/services/StatSvc.js

49 lines
1.1 KiB
JavaScript

const angular = require('angular');
angular.module('StatSvc', []).service('StatService', ['$http', function($http) {
this.getUploads = async () => {
const res = await $http({
method: 'GET',
url: '/api/stats/uploads'
});
return res.data;
};
this.getUploadsWeek = async () => {
let oneWeekAgo = new Date();
oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);
const res = await $http({
method: 'GET',
url: '/api/stats/uploads',
data: {
after: oneWeekAgo
}
});
return res.data;
};
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;
};
}]);