From a4339ea540d072d0683f5298a7bb63893ad1e420 Mon Sep 17 00:00:00 2001 From: trivernis Date: Sat, 18 Jan 2020 10:57:13 +0100 Subject: [PATCH] Fix posts TOP ordering --- src/lib/dataAccess.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/dataAccess.ts b/src/lib/dataAccess.ts index 1ed2885..b713f8a 100644 --- a/src/lib/dataAccess.ts +++ b/src/lib/dataAccess.ts @@ -164,7 +164,7 @@ namespace dataaccess { 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 = '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[]; } }