Sort out story model.
This commit is contained in:
@ -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": [],
|
||||
|
@ -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',
|
||||
|
Reference in New Issue
Block a user