From 4f9061bffb1db5c4df9a7008c13cc2aabb6a8ff8 Mon Sep 17 00:00:00 2001 From: terakilobyte Date: Fri, 5 Jun 2015 14:53:12 -0400 Subject: [PATCH] Sort out story model. --- common/models/story.json | 11 ++--------- server/boot/story.js | 23 +++++++++-------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/common/models/story.json b/common/models/story.json index 2ce2dc5ce4..b10b87ac31 100644 --- a/common/models/story.json +++ b/common/models/story.json @@ -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": [], diff --git a/server/boot/story.js b/server/boot/story.js index 3aac952cc6..915463ffc8 100755 --- a/server/boot/story.js +++ b/server/boot/story.js @@ -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',