Sort out story model.

This commit is contained in:
terakilobyte
2015-06-05 14:53:12 -04:00
parent d782ac9520
commit 4f9061bffb
2 changed files with 11 additions and 23 deletions

View File

@ -14,7 +14,7 @@
},
"timePosted": {
"type": "number",
"default": "0"
"default": 0
},
"link": {
"type": "string",
@ -35,7 +35,7 @@
},
"rank": {
"type": "number",
"default": "-Infinity"
"default": 0
},
"upVotes": {
"type": "array",
@ -53,13 +53,6 @@
"storyLink": {
"type": "string",
"default": ""
},
"difficulty": "string",
"description": "array",
"tests": "array",
"challengeSeed": "array",
"MDNlinks": {
"type": "array"
}
},
"validations": [],

View File

@ -13,7 +13,6 @@ module.exports = function(app) {
var Story = app.models.Story;
router.get('/stories/hotStories', hotJSON);
router.get('/stories/recentStories', recentJSON);
router.get('/stories/comments/:id', comments);
router.post('/stories/comment/', commentSubmit);
router.post('/stories/comment/:id/comment', commentOnCommentSubmit);
@ -44,12 +43,18 @@ module.exports = function(app) {
}
function hotJSON(req, res, next) {
var story = Story.find({}).sort({'timePosted': -1}).limit(1000);
story.exec(function(err, stories) {
//var story = Story.find({}).sort({'timePosted': -1}).limit(1000);
//story.exec(function(err, stories) {
// if (err) {
// return next(err);
// }
//Story.find([{$match: {}},
// {$sort: {'timePosted': -1}},
// {$limit: 1000}], function(err, stories) {
Story.find({order: 'timePosted DESC', limit: 1000}, function(err, stories) {
if (err) {
return next(err);
}
var foundationDate = 1413298800000;
var sliceVal = stories.length >= 100 ? 100 : stories.length;
@ -63,16 +68,6 @@ module.exports = function(app) {
});
}
function recentJSON(req, res, next) {
var story = Story.find({}).sort({'timePosted': -1}).limit(100);
story.exec(function(err, stories) {
if (err) {
return next(err);
}
return res.json(stories);
});
}
function hot(req, res) {
return res.render('stories/index', {
title: 'Hot stories currently trending on Camper News',