Sort out story model.
This commit is contained in:
@ -14,7 +14,7 @@
|
|||||||
},
|
},
|
||||||
"timePosted": {
|
"timePosted": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"default": "0"
|
"default": 0
|
||||||
},
|
},
|
||||||
"link": {
|
"link": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -35,7 +35,7 @@
|
|||||||
},
|
},
|
||||||
"rank": {
|
"rank": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"default": "-Infinity"
|
"default": 0
|
||||||
},
|
},
|
||||||
"upVotes": {
|
"upVotes": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
@ -53,13 +53,6 @@
|
|||||||
"storyLink": {
|
"storyLink": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": ""
|
"default": ""
|
||||||
},
|
|
||||||
"difficulty": "string",
|
|
||||||
"description": "array",
|
|
||||||
"tests": "array",
|
|
||||||
"challengeSeed": "array",
|
|
||||||
"MDNlinks": {
|
|
||||||
"type": "array"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"validations": [],
|
"validations": [],
|
||||||
|
@ -13,7 +13,6 @@ module.exports = function(app) {
|
|||||||
var Story = app.models.Story;
|
var Story = app.models.Story;
|
||||||
|
|
||||||
router.get('/stories/hotStories', hotJSON);
|
router.get('/stories/hotStories', hotJSON);
|
||||||
router.get('/stories/recentStories', recentJSON);
|
|
||||||
router.get('/stories/comments/:id', comments);
|
router.get('/stories/comments/:id', comments);
|
||||||
router.post('/stories/comment/', commentSubmit);
|
router.post('/stories/comment/', commentSubmit);
|
||||||
router.post('/stories/comment/:id/comment', commentOnCommentSubmit);
|
router.post('/stories/comment/:id/comment', commentOnCommentSubmit);
|
||||||
@ -44,12 +43,18 @@ module.exports = function(app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hotJSON(req, res, next) {
|
function hotJSON(req, res, next) {
|
||||||
var story = Story.find({}).sort({'timePosted': -1}).limit(1000);
|
//var story = Story.find({}).sort({'timePosted': -1}).limit(1000);
|
||||||
story.exec(function(err, stories) {
|
//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) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var foundationDate = 1413298800000;
|
var foundationDate = 1413298800000;
|
||||||
|
|
||||||
var sliceVal = stories.length >= 100 ? 100 : stories.length;
|
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) {
|
function hot(req, res) {
|
||||||
return res.render('stories/index', {
|
return res.render('stories/index', {
|
||||||
title: 'Hot stories currently trending on Camper News',
|
title: 'Hot stories currently trending on Camper News',
|
||||||
|
Reference in New Issue
Block a user