Small refactor to reduce unnecessary database queries and remove duplicated functions (#33779)

(cherry picked from commit 6c8fb8d455cfe25d5aa966674624bce99fba1735)
This commit is contained in:
Lunny Xiao 2025-03-04 10:25:20 -08:00 committed by Gusted
parent 49694242d4
commit 0a52be2a04
No known key found for this signature in database
GPG key ID: FD821B732837125F
6 changed files with 22 additions and 7 deletions

View file

@ -546,6 +546,9 @@ func GetIssueByID(ctx context.Context, id int64) (*Issue, error) {
// If keepOrder is true, the order of the returned issues will be the same as the given IDs.
func GetIssuesByIDs(ctx context.Context, issueIDs []int64, keepOrder ...bool) (IssueList, error) {
issues := make([]*Issue, 0, len(issueIDs))
if len(issueIDs) == 0 {
return issues, nil
}
if err := db.GetEngine(ctx).In("id", issueIDs).Find(&issues); err != nil {
return nil, err