Skip to content

Commit 6f7d70f

Browse files
authored
Reduce unnecessary database queries on actions table (#30509)
1 parent 38147d0 commit 6f7d70f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

models/activities/action_list.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ func (actions ActionList) loadRepoOwner(ctx context.Context, userMap map[int64]*
8383
_, alreadyLoaded := userMap[action.Repo.OwnerID]
8484
return action.Repo.OwnerID, !alreadyLoaded
8585
})
86+
if len(missingUserIDs) == 0 {
87+
return nil
88+
}
8689

8790
if err := db.GetEngine(ctx).
8891
In("id", missingUserIDs).
@@ -129,6 +132,9 @@ func (actions ActionList) LoadComments(ctx context.Context) error {
129132
commentIDs = append(commentIDs, action.CommentID)
130133
}
131134
}
135+
if len(commentIDs) == 0 {
136+
return nil
137+
}
132138

133139
commentsMap := make(map[int64]*issues_model.Comment, len(commentIDs))
134140
if err := db.GetEngine(ctx).In("id", commentIDs).Find(&commentsMap); err != nil {

0 commit comments

Comments
 (0)