Skip to content

Commit 19ca47a

Browse files
committed
move the function
1 parent 2bd70c7 commit 19ca47a

File tree

9 files changed

+29
-23
lines changed

9 files changed

+29
-23
lines changed

models/action_list.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"code.gitea.io/gitea/models/db"
1111
repo_model "code.gitea.io/gitea/models/repo"
1212
user_model "code.gitea.io/gitea/models/user"
13+
"code.gitea.io/gitea/modules/container"
1314
)
1415

1516
// ActionList defines a list of actions
@@ -22,7 +23,7 @@ func (actions ActionList) getUserIDs() []int64 {
2223
userIDs[action.ActUserID] = struct{}{}
2324
}
2425
}
25-
return db.KeysInt64(userIDs)
26+
return container.KeysInt64(userIDs)
2627
}
2728

2829
func (actions ActionList) loadUsers(e db.Engine) (map[int64]*user_model.User, error) {
@@ -52,7 +53,7 @@ func (actions ActionList) getRepoIDs() []int64 {
5253
repoIDs[action.RepoID] = struct{}{}
5354
}
5455
}
55-
return db.KeysInt64(repoIDs)
56+
return container.KeysInt64(repoIDs)
5657
}
5758

5859
func (actions ActionList) loadRepositories(e db.Engine) error {

models/issue_comment_list.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"code.gitea.io/gitea/models/db"
1111
repo_model "code.gitea.io/gitea/models/repo"
1212
user_model "code.gitea.io/gitea/models/user"
13+
"code.gitea.io/gitea/modules/container"
1314
)
1415

1516
// CommentList defines a list of comments
@@ -22,7 +23,7 @@ func (comments CommentList) getPosterIDs() []int64 {
2223
posterIDs[comment.PosterID] = struct{}{}
2324
}
2425
}
25-
return db.KeysInt64(posterIDs)
26+
return container.KeysInt64(posterIDs)
2627
}
2728

2829
func (comments CommentList) loadPosters(e db.Engine) error {
@@ -75,7 +76,7 @@ func (comments CommentList) getLabelIDs() []int64 {
7576
ids[comment.LabelID] = struct{}{}
7677
}
7778
}
78-
return db.KeysInt64(ids)
79+
return container.KeysInt64(ids)
7980
}
8081

8182
func (comments CommentList) loadLabels(e db.Engine) error {
@@ -125,7 +126,7 @@ func (comments CommentList) getMilestoneIDs() []int64 {
125126
ids[comment.MilestoneID] = struct{}{}
126127
}
127128
}
128-
return db.KeysInt64(ids)
129+
return container.KeysInt64(ids)
129130
}
130131

131132
func (comments CommentList) loadMilestones(e db.Engine) error {
@@ -168,7 +169,7 @@ func (comments CommentList) getOldMilestoneIDs() []int64 {
168169
ids[comment.OldMilestoneID] = struct{}{}
169170
}
170171
}
171-
return db.KeysInt64(ids)
172+
return container.KeysInt64(ids)
172173
}
173174

174175
func (comments CommentList) loadOldMilestones(e db.Engine) error {
@@ -211,7 +212,7 @@ func (comments CommentList) getAssigneeIDs() []int64 {
211212
ids[comment.AssigneeID] = struct{}{}
212213
}
213214
}
214-
return db.KeysInt64(ids)
215+
return container.KeysInt64(ids)
215216
}
216217

217218
func (comments CommentList) loadAssignees(e db.Engine) error {
@@ -267,7 +268,7 @@ func (comments CommentList) getIssueIDs() []int64 {
267268
ids[comment.IssueID] = struct{}{}
268269
}
269270
}
270-
return db.KeysInt64(ids)
271+
return container.KeysInt64(ids)
271272
}
272273

273274
// Issues returns all the issues of comments
@@ -342,7 +343,7 @@ func (comments CommentList) getDependentIssueIDs() []int64 {
342343
ids[comment.DependentIssueID] = struct{}{}
343344
}
344345
}
345-
return db.KeysInt64(ids)
346+
return container.KeysInt64(ids)
346347
}
347348

348349
func (comments CommentList) loadDependentIssues(ctx context.Context) error {
@@ -444,7 +445,7 @@ func (comments CommentList) getReviewIDs() []int64 {
444445
ids[comment.ReviewID] = struct{}{}
445446
}
446447
}
447-
return db.KeysInt64(ids)
448+
return container.KeysInt64(ids)
448449
}
449450

450451
func (comments CommentList) loadReviews(e db.Engine) error {

models/issue_list.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"code.gitea.io/gitea/models/db"
1111
repo_model "code.gitea.io/gitea/models/repo"
1212
user_model "code.gitea.io/gitea/models/user"
13+
"code.gitea.io/gitea/modules/container"
1314

1415
"xorm.io/builder"
1516
)
@@ -32,7 +33,7 @@ func (issues IssueList) getRepoIDs() []int64 {
3233
repoIDs[issue.RepoID] = struct{}{}
3334
}
3435
}
35-
return db.KeysInt64(repoIDs)
36+
return container.KeysInt64(repoIDs)
3637
}
3738

3839
func (issues IssueList) loadRepositories(e db.Engine) ([]*repo_model.Repository, error) {
@@ -83,7 +84,7 @@ func (issues IssueList) getPosterIDs() []int64 {
8384
posterIDs[issue.PosterID] = struct{}{}
8485
}
8586
}
86-
return db.KeysInt64(posterIDs)
87+
return container.KeysInt64(posterIDs)
8788
}
8889

8990
func (issues IssueList) loadPosters(e db.Engine) error {
@@ -189,7 +190,7 @@ func (issues IssueList) getMilestoneIDs() []int64 {
189190
ids[issue.MilestoneID] = struct{}{}
190191
}
191192
}
192-
return db.KeysInt64(ids)
193+
return container.KeysInt64(ids)
193194
}
194195

195196
func (issues IssueList) loadMilestones(e db.Engine) error {

models/issues/reaction.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"code.gitea.io/gitea/models/db"
1313
repo_model "code.gitea.io/gitea/models/repo"
1414
user_model "code.gitea.io/gitea/models/user"
15+
"code.gitea.io/gitea/modules/container"
1516
"code.gitea.io/gitea/modules/setting"
1617
"code.gitea.io/gitea/modules/timeutil"
1718

@@ -132,7 +133,7 @@ func (opts *FindReactionsOptions) toConds() builder.Cond {
132133
}
133134

134135
// FindCommentReactions returns a ReactionList of all reactions from an comment
135-
func FindCommentReactions(issueID int64, commentID int64) (ReactionList, int64, error) {
136+
func FindCommentReactions(issueID, commentID int64) (ReactionList, int64, error) {
136137
return FindReactions(db.DefaultContext, FindReactionsOptions{
137138
IssueID: issueID,
138139
CommentID: commentID,
@@ -315,7 +316,7 @@ func (list ReactionList) getUserIDs() []int64 {
315316
userIDs[reaction.UserID] = struct{}{}
316317
}
317318
}
318-
return db.KeysInt64(userIDs)
319+
return container.KeysInt64(userIDs)
319320
}
320321

321322
func valuesUser(m map[int64]*user_model.User) []*user_model.User {

models/issues/reaction_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"testing"
99

1010
"code.gitea.io/gitea/models/db"
11-
"code.gitea.io/gitea/models/unittest"
1211
repo_model "code.gitea.io/gitea/models/repo"
12+
"code.gitea.io/gitea/models/unittest"
1313
user_model "code.gitea.io/gitea/models/user"
1414
"code.gitea.io/gitea/modules/setting"
1515

@@ -148,7 +148,7 @@ func TestIssueCommentDeleteReaction(t *testing.T) {
148148
addReaction(t, user4.ID, issue1ID, comment1ID, "+1")
149149

150150
reactionsList, _, err := FindReactions(db.DefaultContext, FindReactionsOptions{
151-
IssueID: issue1ID,
151+
IssueID: issue1ID,
152152
CommentID: comment1ID,
153153
})
154154
assert.NoError(t, err)

models/migrate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
"testing"
1010

1111
"code.gitea.io/gitea/models/foreignreference"
12+
issues_model "code.gitea.io/gitea/models/issues"
1213
repo_model "code.gitea.io/gitea/models/repo"
1314
"code.gitea.io/gitea/models/unittest"
1415
user_model "code.gitea.io/gitea/models/user"
15-
issues_model "code.gitea.io/gitea/models/issues"
1616

1717
"github.com/stretchr/testify/assert"
1818
)

models/notification.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
repo_model "code.gitea.io/gitea/models/repo"
1616
"code.gitea.io/gitea/models/unit"
1717
user_model "code.gitea.io/gitea/models/user"
18+
"code.gitea.io/gitea/modules/container"
1819
"code.gitea.io/gitea/modules/log"
1920
"code.gitea.io/gitea/modules/setting"
2021
"code.gitea.io/gitea/modules/timeutil"
@@ -520,7 +521,7 @@ func (nl NotificationList) getPendingRepoIDs() []int64 {
520521
ids[notification.RepoID] = struct{}{}
521522
}
522523
}
523-
return db.KeysInt64(ids)
524+
return container.KeysInt64(ids)
524525
}
525526

526527
// LoadRepos loads repositories from database
@@ -596,7 +597,7 @@ func (nl NotificationList) getPendingIssueIDs() []int64 {
596597
ids[notification.IssueID] = struct{}{}
597598
}
598599
}
599-
return db.KeysInt64(ids)
600+
return container.KeysInt64(ids)
600601
}
601602

602603
// LoadIssues loads issues from database
@@ -682,7 +683,7 @@ func (nl NotificationList) getPendingCommentIDs() []int64 {
682683
ids[notification.CommentID] = struct{}{}
683684
}
684685
}
685-
return db.KeysInt64(ids)
686+
return container.KeysInt64(ids)
686687
}
687688

688689
// LoadComments loads comments from database

models/repo_list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
repo_model "code.gitea.io/gitea/models/repo"
1414
"code.gitea.io/gitea/models/unit"
1515
user_model "code.gitea.io/gitea/models/user"
16+
"code.gitea.io/gitea/modules/container"
1617
"code.gitea.io/gitea/modules/structs"
1718
"code.gitea.io/gitea/modules/util"
1819

@@ -62,7 +63,7 @@ func (repos RepositoryList) loadAttributes(e db.Engine) error {
6263
users := make(map[int64]*user_model.User, len(set))
6364
if err := e.
6465
Where("id > 0").
65-
In("id", db.KeysInt64(set)).
66+
In("id", container.KeysInt64(set)).
6667
Find(&users); err != nil {
6768
return fmt.Errorf("find users: %v", err)
6869
}

models/db/map.go renamed to modules/container/map.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5-
package db
5+
package container
66

77
// KeysInt64 returns keys slice for a map with int64 key
88
func KeysInt64(m map[int64]struct{}) []int64 {

0 commit comments

Comments
 (0)