|
|
@ -164,7 +164,7 @@ namespace dataaccess {
|
|
|
|
SELECT *,
|
|
|
|
SELECT *,
|
|
|
|
(SELECT count(*) FROM post_votes WHERE vote_type = 'UPVOTE' AND post_id = posts.id) AS upvotes ,
|
|
|
|
(SELECT count(*) FROM post_votes WHERE vote_type = 'UPVOTE' AND post_id = posts.id) AS upvotes ,
|
|
|
|
(SELECT count(*) FROM post_votes WHERE vote_type = 'DOWNVOTE' AND post_id = posts.id) AS downvotes
|
|
|
|
(SELECT count(*) FROM post_votes WHERE vote_type = 'DOWNVOTE' AND post_id = posts.id) AS downvotes
|
|
|
|
FROM posts) AS a ORDER BY (a.upvotes - a.downvotes), a.id DESC LIMIT ? OFFSET ?`,
|
|
|
|
FROM posts) AS a ORDER BY (a.upvotes - a.downvotes) DESC, a.upvotes DESC, a.id LIMIT ? OFFSET ?`,
|
|
|
|
{replacements: [first, offset], mapToModel: true, model: models.Post}) as models.Post[];
|
|
|
|
{replacements: [first, offset], mapToModel: true, model: models.Post}) as models.Post[];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|