0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-13 08:55:40 +02:00

fix: address lunny's review comments

- use single query with Cols("comment_id").Table("commit_comment")
  instead of loading full CommitComment structs
- remove models/repo/commit_comment.go entirely
This commit is contained in:
yuvrajangadsingh 2026-03-09 02:16:57 +05:30
parent 9c92458cc0
commit 6d0c41ca94
No known key found for this signature in database
2 changed files with 4 additions and 17 deletions

View File

@ -35,22 +35,17 @@ type CommitCommentsForDiff map[string]*FileCommitComments
// FindCommitCommentsByCommitSHA returns all comments for a given commit in a repo.
func FindCommitCommentsByCommitSHA(ctx context.Context, repoID int64, commitSHA string) ([]*Comment, error) {
var refs []CommitComment
if err := db.GetEngine(ctx).
var commentIDs []int64
if err := db.GetEngine(ctx).Cols("comment_id").Table("commit_comment").
Where("repo_id = ? AND commit_sha = ?", repoID, commitSHA).
Find(&refs); err != nil {
Find(&commentIDs); err != nil {
return nil, err
}
if len(refs) == 0 {
if len(commentIDs) == 0 {
return nil, nil
}
commentIDs := make([]int64, 0, len(refs))
for _, ref := range refs {
commentIDs = append(commentIDs, ref.CommentID)
}
comments := make([]*Comment, 0, len(commentIDs))
if err := db.GetEngine(ctx).
In("id", commentIDs).

View File

@ -1,8 +0,0 @@
// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
// This file intentionally left minimal. The CommitComment junction table
// and all query methods now live in models/issues/commit_comment.go
// alongside the Comment model they reference.
package repo