Fix daily upload counting
This commit is contained in:
parent
d30b0987ad
commit
8e47c74b68
3 changed files with 4 additions and 3 deletions
|
@ -39,7 +39,7 @@ module.exports = function* (next) {
|
||||||
this.assert(!user.activationCode, 401, '{"error": {"message": "Account has not been activated.", "code": 603}}');
|
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 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 = {
|
const normalisedUser = {
|
||||||
'id': user._id,
|
'id': user._id,
|
||||||
|
|
|
@ -58,7 +58,7 @@ export function* setupSession(user) {
|
||||||
'maxFileSize': 20971520,
|
'maxFileSize': 20971520,
|
||||||
'joined': user.joined,
|
'joined': user.joined,
|
||||||
'plan': user.type || 'Free',
|
'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,
|
'token': token,
|
||||||
'md5': crypto.createHash('md5').update(user.email).digest('hex')
|
'md5': crypto.createHash('md5').update(user.email).digest('hex')
|
||||||
};
|
};
|
||||||
|
|
|
@ -92,7 +92,8 @@
|
||||||
plan: "<%= user.plan %>",
|
plan: "<%= user.plan %>",
|
||||||
maxFileSize: <%= user.maxFileSize %>,
|
maxFileSize: <%= user.maxFileSize %>,
|
||||||
token: "<%= user.token %>",
|
token: "<%= user.token %>",
|
||||||
md5: "<%= user.md5 %>"
|
md5: "<%= user.md5 %>",
|
||||||
|
uploadsToday: "<%= user.uploadsToday %>"
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue