Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Prince213 committed Jul 6, 2024
2 parents 5e518cd + bd479fb commit 89b0711
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/controllers/comments/recent.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"coursebench-backend/pkg/database"
"coursebench-backend/pkg/errors"
"coursebench-backend/pkg/models"

"github.com/gofiber/fiber/v2"
)

Expand All @@ -34,13 +35,13 @@ func RecentComment(c *fiber.Ctx) (err error) {
db := database.GetDB()
var comments []models.Comment
err = db.Preload("User").Preload("CourseGroup").Preload("CourseGroup.Course").Preload("CourseGroup.Teachers").
Order("update_time DESC").Limit(30).Find(&comments).Error
Order("update_time DESC").Limit(100).Find(&comments).Error
if err != nil {
return errors.Wrap(err, errors.DatabaseError)
}
var likeResult []CommentLikeResult
if uid != 0 {
db.Raw("SELECT comment_likes.comment_id, comment_likes.is_like from comments, comment_likes where comment_likes.user_id = ? and comment_likes.comment_id = comments.id and comment_likes.deleted_at is NULL and comments.deleted_at is NULL order by create_time desc LIMIT 30",
db.Raw("SELECT comment_likes.comment_id, comment_likes.is_like from comments, comment_likes where comment_likes.user_id = ? and comment_likes.comment_id = comments.id and comment_likes.deleted_at is NULL and comments.deleted_at is NULL order by create_time desc LIMIT 100",
uid).Scan(&likeResult)
}
var response []CommentResponse
Expand Down

0 comments on commit 89b0711

Please sign in to comment.