File tree 3 files changed +13
-23
lines changed
3 files changed +13
-23
lines changed Original file line number Diff line number Diff line change @@ -36,16 +36,9 @@ func (runners RunnerList) LoadOwners(ctx context.Context) error {
36
36
}
37
37
38
38
func (runners RunnerList ) getRepoIDs () []int64 {
39
- repoIDs := make (container.Set [int64 ], len (runners ))
40
- for _ , runner := range runners {
41
- if runner .RepoID == 0 {
42
- continue
43
- }
44
- if _ , ok := repoIDs [runner .RepoID ]; ! ok {
45
- repoIDs [runner .RepoID ] = struct {}{}
46
- }
47
- }
48
- return repoIDs .Values ()
39
+ return container .FilterSlice (runners , func (runner * ActionRunner ) (int64 , bool ) {
40
+ return runner .RepoID , runner .RepoID > 0
41
+ })
49
42
}
50
43
51
44
func (runners RunnerList ) LoadRepos (ctx context.Context ) error {
Original file line number Diff line number Diff line change @@ -190,14 +190,12 @@ func (nl NotificationList) LoadAttributes(ctx context.Context) error {
190
190
}
191
191
192
192
func (nl NotificationList ) getPendingRepoIDs () []int64 {
193
- ids := make (container.Set [int64 ], len (nl ))
194
- for _ , notification := range nl {
195
- if notification .Repository != nil {
196
- continue
193
+ return container .FilterSlice (nl , func (n * Notification ) (int64 , bool ) {
194
+ if n .Repository != nil {
195
+ return 0 , false
197
196
}
198
- ids .Add (notification .RepoID )
199
- }
200
- return ids .Values ()
197
+ return n .RepoID , true
198
+ })
201
199
}
202
200
203
201
// LoadRepos loads repositories from database
Original file line number Diff line number Diff line change @@ -21,16 +21,15 @@ type IssueList []*Issue
21
21
22
22
// get the repo IDs to be loaded later, these IDs are for issue.Repo and issue.PullRequest.HeadRepo
23
23
func (issues IssueList ) getRepoIDs () []int64 {
24
- repoIDs := make (container.Set [int64 ], len (issues ))
25
- for _ , issue := range issues {
24
+ return container .FilterSlice (issues , func (issue * Issue ) (int64 , bool ) {
26
25
if issue .Repo == nil {
27
- repoIDs . Add ( issue .RepoID )
26
+ return issue .RepoID , true
28
27
}
29
28
if issue .PullRequest != nil && issue .PullRequest .HeadRepo == nil {
30
- repoIDs . Add ( issue .PullRequest .HeadRepoID )
29
+ return issue .PullRequest .HeadRepoID , true
31
30
}
32
- }
33
- return repoIDs . Values ( )
31
+ return 0 , false
32
+ } )
34
33
}
35
34
36
35
// LoadRepositories loads issues' all repositories
You can’t perform that action at this time.
0 commit comments