Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(controllers/comments.RecentComment): change limit to 100 #39

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading