🐛 Trying to fix get featured posts failed

This commit is contained in:
LittleSheep 2024-12-10 00:02:31 +08:00
parent 03f72d548d
commit fb33f4abc9

View File

@ -18,7 +18,7 @@ func GetFeaturedPosts(count int) ([]models.Post, error) {
var posts []models.Post
if err := database.C.Raw(`
SELECT p.*
SELECT p.*, t.social_points
FROM posts p
JOIN (
SELECT
@ -32,7 +32,7 @@ func GetFeaturedPosts(count int) ([]models.Post, error) {
LIMIT ?
) t ON p.id = t.post_id
ORDER BY t.social_points DESC, p.published_at DESC
`, deadline, count).Scan(&posts).Error; err != nil {
`, deadline, count).Scan(&posts).Error; err != nil {
return posts, err
}