Skip to content

Commit

Permalink
Merge pull request #248 from SoftwareEngineeringDaily/hot-fixes
Browse files Browse the repository at this point in the history
Hot fixes
  • Loading branch information
jasonify authored May 23, 2018
2 parents ba8cc7b + 0d33001 commit dd4ccfe
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion server/controllers/feed.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function getLinks(req) {
if (req.user) query.user = req.user;

const {
limit = 15,
limit = 10,
} = req.query;

query.limit = limit;
Expand Down
22 changes: 14 additions & 8 deletions server/controllers/post.controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import raccoon from 'raccoon';
import mongoose from 'mongoose';
// import mongoose from 'mongoose';

import Post from '../models/post.model';
import {
Expand Down Expand Up @@ -176,8 +175,10 @@ function list(req, res, next) {
* $ref: '#/responses/NotFound'
*/

function recommendations(req, res, next) {
const numberOfRecommendations = 10;
function recommendations(req, res) {
// const numberOfRecommendations = 10;
res.json([]);
/*
raccoon
.recommendFor(req.user._id.toString(), numberOfRecommendations)
.then((recommendationsFound) => {
Expand All @@ -193,25 +194,30 @@ function recommendations(req, res, next) {
.catch((e) => {
next(e);
});
*/
}

function upvote(req, res, next) {
/*
const userIdString = req.user._id.toString();
const postIdString = req.post._id.toString();
if (req.liked) {
raccoon.liked(userIdString, postIdString);
// raccoon.liked(userIdString, postIdString);
} else if (req.unliked) {
raccoon.unliked(userIdString, postIdString);
// raccoon.unliked(userIdString, postIdString);
}
*/
next();
}

function downvote(req, res, next) {
/*
if (req.undisliked) {
raccoon.undisliked(req.user._id.toString(), req.post._id.toString());
// raccoon.undisliked(req.user._id.toString(), req.post._id.toString());
} else if (req.disliked) {
raccoon.disliked(req.user._id.toString(), req.post._id.toString());
// raccoon.disliked(req.user._id.toString(), req.post._id.toString());
}
*/
next();
}

Expand Down
4 changes: 4 additions & 0 deletions server/models/feedItem.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ const FeedItemSchema = new Schema({
FeedItemSchema.statics = {
// This doesn't paginate currently:
list({
limit = 10,
user = null
} = {}) {
const query = { user };
const limitOption = parseInt(limit, 10);

return this.find(query)
.populate('user', '-password')
// Deep populate: https://github.com/Automattic/mongoose/issues/5696
.populate({ path: 'relatedLink', populate: { path: 'author' } })
.populate({ path: 'relatedLink', populate: { path: 'post' } })
// .populate({ path: 'relatedLink', populate: { path: 'post', populate: { path: 'thread' } } })
.sort({ randomOrder: -1 })
.limit(limitOption)
.exec()
.then((itemsFound) => {
const foundProcessed = itemsFound.map((item) => {
Expand Down

0 comments on commit dd4ccfe

Please sign in to comment.