🐛 Fix feed API sorting issue

This commit is contained in:
2024-03-07 23:39:51 +08:00
parent ad88fe312f
commit fa5b166d88
3 changed files with 34 additions and 19 deletions

View File

@ -62,7 +62,7 @@ func listFeed(c *fiber.Ctx) error {
GROUP BY article_id, moment_id) as reactions
ON (feed.model_type = 'article' AND feed.id = reactions.article_id) OR
(feed.model_type = 'moment' AND feed.id = reactions.moment_id)
WHERE %s LIMIT ? OFFSET ?`, userTable, commentTable, reactionTable, whereCondition),
WHERE %s ORDER BY feed.created_at desc LIMIT ? OFFSET ?`, userTable, commentTable, reactionTable, whereCondition),
database.C.Select(queryArticle).Model(&models.Article{}),
database.C.Select(queryMoment).Model(&models.Moment{}),
take,