User will now get a point for posting a story as well as receiving an upvote on a posted story

This commit is contained in:
Nathan Leniz
2015-03-22 20:07:08 +09:00
parent 6e0da758e0
commit 31ce7b686a

View File

@ -19,7 +19,7 @@ function hotRank(timeValue, rank) {
*/ */
var hotness; var hotness;
var z = Math.log(rank) / Math.log(10); var z = Math.log(rank) / Math.log(10);
hotness = z + (timeValue / 115200000); hotness = z + (timeValue / 172800000);
return hotness; return hotness;
} }
@ -38,7 +38,8 @@ exports.hotJSON = function(req, res) {
return res.json(stories.map(function(elem) { return res.json(stories.map(function(elem) {
return elem; return elem;
}).sort(function(a, b) { }).sort(function(a, b) {
return hotRank(b.timePosted - foundationDate, b.rank, b.headline) - hotRank(a.timePosted - foundationDate, a.rank, a.headline); return hotRank(b.timePosted - foundationDate, b.rank, b.headline)
- hotRank(a.timePosted - foundationDate, a.rank, a.headline);
}).slice(0, sliceVal)); }).slice(0, sliceVal));
}); });
@ -221,6 +222,17 @@ exports.upvote = function(req, res, next) {
); );
story.markModified('rank'); story.markModified('rank');
story.save(); story.save();
User.find({'_id': story.author.userId}, function(err, user) {
'use strict';
if (err) {
return next(err);
}
// todo debug
debug('This is the user in upvote', user);
user = user.pop();
user.progressTimestamps.push(Date.now());
user.save();
});
return res.send(story); return res.send(story);
}); });
}; };
@ -332,6 +344,9 @@ exports.storySubmission = function(req, res) {
metaDescription: data.storyMetaDescription metaDescription: data.storyMetaDescription
}); });
req.user.progressTimestamps.push(Date.now());
req.user.save();
story.save(function(err) { story.save(function(err) {
if (err) { if (err) {
return res.status(500); return res.status(500);