mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-12-01 14:26:10 +01:00
Reduce unnecessary database queries on actions table (#30509)
(cherry picked from commit 6f7d70fb3d2624507c3ccd5640f6d1837259c27d)
This commit is contained in:
parent
cfb8617fc8
commit
77c4a5e95b
|
@ -83,6 +83,9 @@ func (actions ActionList) loadRepoOwner(ctx context.Context, userMap map[int64]*
|
||||||
_, alreadyLoaded := userMap[action.Repo.OwnerID]
|
_, alreadyLoaded := userMap[action.Repo.OwnerID]
|
||||||
return action.Repo.OwnerID, !alreadyLoaded
|
return action.Repo.OwnerID, !alreadyLoaded
|
||||||
})
|
})
|
||||||
|
if len(missingUserIDs) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if err := db.GetEngine(ctx).
|
if err := db.GetEngine(ctx).
|
||||||
In("id", missingUserIDs).
|
In("id", missingUserIDs).
|
||||||
|
@ -129,6 +132,9 @@ func (actions ActionList) LoadComments(ctx context.Context) error {
|
||||||
commentIDs = append(commentIDs, action.CommentID)
|
commentIDs = append(commentIDs, action.CommentID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(commentIDs) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
commentsMap := make(map[int64]*issues_model.Comment, len(commentIDs))
|
commentsMap := make(map[int64]*issues_model.Comment, len(commentIDs))
|
||||||
if err := db.GetEngine(ctx).In("id", commentIDs).Find(&commentsMap); err != nil {
|
if err := db.GetEngine(ctx).In("id", commentIDs).Find(&commentsMap); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue