Skip to content

Commit 65fe44f

Browse files
committed
use new options
1 parent a0a9de8 commit 65fe44f

File tree

7 files changed

+15
-21
lines changed

7 files changed

+15
-21
lines changed

models/issue_label.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,9 @@ func (label *Label) CalOpenIssues() {
5757

5858
// CalOpenOrgIssues calculates the open issues of a label for a specific repo
5959
func (label *Label) CalOpenOrgIssues(repoID, labelID int64) {
60-
repoIDs := []int64{repoID}
61-
labelIDs := []int64{labelID}
62-
6360
counts, _ := CountIssuesByRepo(&IssuesOptions{
64-
RepoIDs: repoIDs,
65-
LabelIDs: labelIDs,
61+
RepoID: repoID,
62+
LabelIDs: []int64{labelID},
6663
})
6764

6865
for _, count := range counts {

models/issue_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
user_model "code.gitea.io/gitea/models/user"
2222

2323
"github.com/stretchr/testify/assert"
24+
"xorm.io/builder"
2425
)
2526

2627
func TestIssue_ReplaceLabels(t *testing.T) {
@@ -157,7 +158,7 @@ func TestIssues(t *testing.T) {
157158
},
158159
{
159160
IssuesOptions{
160-
RepoIDs: []int64{1, 3},
161+
RepoCond: builder.In("repo_id", 1, 3),
161162
SortType: "oldest",
162163
ListOptions: db.ListOptions{
163164
Page: 1,
@@ -344,7 +345,7 @@ func TestGetRepoIDsForIssuesOptions(t *testing.T) {
344345
},
345346
{
346347
IssuesOptions{
347-
RepoIDs: []int64{1, 2},
348+
RepoCond: builder.In("repo_id", 1, 2),
348349
},
349350
[]int64{1, 2},
350351
},

modules/indexer/issues/indexer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func populateIssueIndexer(ctx context.Context) {
321321
// UpdateRepoIndexer add/update all issues of the repositories
322322
func UpdateRepoIndexer(repo *repo_model.Repository) {
323323
is, err := models.Issues(&models.IssuesOptions{
324-
RepoIDs: []int64{repo.ID},
324+
RepoID: repo.ID,
325325
IsClosed: util.OptionalBoolNone,
326326
IsPull: util.OptionalBoolNone,
327327
})

routers/api/v1/repo/issue.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ func SearchIssues(ctx *context.APIContext) {
175175
opts.TeamID = team.ID
176176
}
177177

178+
repoCond := models.SearchRepositoryCondition(opts)
178179
repoIDs, _, err := models.SearchRepositoryIDs(opts)
179180
if err != nil {
180181
ctx.Error(http.StatusInternalServerError, "SearchRepositoryByName", err)
@@ -235,7 +236,7 @@ func SearchIssues(ctx *context.APIContext) {
235236
Page: ctx.FormInt("page"),
236237
PageSize: limit,
237238
},
238-
RepoIDs: repoIDs,
239+
RepoCond: repoCond,
239240
IsClosed: isClosed,
240241
IssueIDs: issueIDs,
241242
IncludedLabelNames: includedLabelNames,
@@ -462,7 +463,7 @@ func ListIssues(ctx *context.APIContext) {
462463
if len(keyword) == 0 || len(issueIDs) > 0 || len(labelIDs) > 0 {
463464
issuesOpt := &models.IssuesOptions{
464465
ListOptions: listOptions,
465-
RepoIDs: []int64{ctx.Repo.Repository.ID},
466+
RepoID: ctx.Repo.Repository.ID,
466467
IsClosed: isClosed,
467468
IssueIDs: issueIDs,
468469
LabelIDs: labelIDs,

routers/web/repo/issue.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
232232
Page: pager.Paginater.Current(),
233233
PageSize: setting.UI.IssuePagingNum,
234234
},
235-
RepoIDs: []int64{repo.ID},
235+
RepoID: repo.ID,
236236
AssigneeID: assigneeID,
237237
PosterID: posterID,
238238
MentionedID: mentionedID,
@@ -2167,6 +2167,7 @@ func SearchIssues(ctx *context.Context) {
21672167
opts.TeamID = team.ID
21682168
}
21692169

2170+
repoCond := models.SearchRepositoryCondition(opts)
21702171
repoIDs, _, err := models.SearchRepositoryIDs(opts)
21712172
if err != nil {
21722173
ctx.Error(http.StatusInternalServerError, "SearchRepositoryByName", err.Error())
@@ -2227,7 +2228,7 @@ func SearchIssues(ctx *context.Context) {
22272228
Page: ctx.FormInt("page"),
22282229
PageSize: limit,
22292230
},
2230-
RepoIDs: repoIDs,
2231+
RepoCond: repoCond,
22312232
IsClosed: isClosed,
22322233
IssueIDs: issueIDs,
22332234
IncludedLabelNames: includedLabelNames,
@@ -2403,7 +2404,7 @@ func ListIssues(ctx *context.Context) {
24032404
if len(keyword) == 0 || len(issueIDs) > 0 || len(labelIDs) > 0 {
24042405
issuesOpt := &models.IssuesOptions{
24052406
ListOptions: listOptions,
2406-
RepoIDs: []int64{ctx.Repo.Repository.ID},
2407+
RepoID: ctx.Repo.Repository.ID,
24072408
IsClosed: isClosed,
24082409
IssueIDs: issueIDs,
24092410
LabelIDs: labelIDs,

routers/web/user/home.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -463,13 +463,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
463463
// to check if it's in the team(which possible isn't the case).
464464
opts.User = nil
465465
}
466-
userRepoIDs, _, err := models.SearchRepositoryIDs(repoOpts)
467-
if err != nil {
468-
ctx.ServerError("models.SearchRepositoryIDs: %v", err)
469-
return
470-
}
471-
472-
opts.RepoIDs = userRepoIDs
466+
opts.RepoCond = models.SearchRepositoryCondition(repoOpts)
473467
}
474468

475469
// keyword holds the search term entered into the search field.

services/migrations/gitea_uploader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func TestGiteaUploadRepo(t *testing.T) {
105105
assert.Len(t, releases, 1)
106106

107107
issues, err := models.Issues(&models.IssuesOptions{
108-
RepoIDs: []int64{repo.ID},
108+
RepoID: repo.ID,
109109
IsPull: util.OptionalBoolFalse,
110110
SortType: "oldest",
111111
})

0 commit comments

Comments
 (0)