added back needed stats Controller

This commit is contained in:
bill bittner 2018-01-22 22:05:16 -08:00
parent 3aefd43303
commit bac7930983

View file

@ -0,0 +1,41 @@
const logger = require('winston');
const db = require('../models');
module.exports = {
getTrendingClaims (startDate) {
logger.debug('retrieving trending');
return new Promise((resolve, reject) => {
// get the raw requests data
db.getTrendingFiles(startDate)
.then(fileArray => {
let claimsPromiseArray = [];
if (fileArray) {
fileArray.forEach(file => {
claimsPromiseArray.push(db.Claim.resolveClaim(file.name, file.claimId));
});
return Promise.all(claimsPromiseArray);
}
})
.then(claimsArray => {
resolve(claimsArray);
})
.catch(error => {
reject(error);
});
});
},
getRecentClaims () {
logger.debug('retrieving most recent claims');
return new Promise((resolve, reject) => {
// get the raw requests data
db.File.getRecentClaims()
.then(results => {
resolve(results);
})
.catch(error => {
logger.error('sequelize error', error);
reject(error);
});
});
},
};