Fix daily upload counting

This commit is contained in:
Jonathan Cremin 2015-08-22 19:23:17 +01:00
parent d30b0987ad
commit 8e47c74b68
3 changed files with 4 additions and 3 deletions

View file

@ -39,7 +39,7 @@ module.exports = function* (next) {
this.assert(!user.activationCode, 401, '{"error": {"message": "Account has not been activated.", "code": 603}}');
const uploadedTotal = yield Files.count({owner: user._id, status: {'$ne': 'deleted'}});
const uploadedToday = yield Files.count({'owner': user._id, 'time_added': {'$gt': Date.now()}});
const uploadedToday = yield Files.count({owner: user._id, 'time_added': {'$gt': Math.ceil(Date.now()/1000)-86400}});
const normalisedUser = {
'id': user._id,

View file

@ -58,7 +58,7 @@ export function* setupSession(user) {
'maxFileSize': 20971520,
'joined': user.joined,
'plan': user.type || 'Free',
'uploadsToday': 0,
'uploadsToday': yield this.db.Files.count({owner: user._id, 'time_added': {'$gt': Math.ceil(Date.now()/1000)-86400}}),
'token': token,
'md5': crypto.createHash('md5').update(user.email).digest('hex')
};

View file

@ -92,7 +92,8 @@
plan: "<%= user.plan %>",
maxFileSize: <%= user.maxFileSize %>,
token: "<%= user.token %>",
md5: "<%= user.md5 %>"
md5: "<%= user.md5 %>",
uploadsToday: "<%= user.uploadsToday %>"
};
</script>
<% } %>