@@ -88,6 +88,7 @@ func SearchIssues(ctx *context.APIContext) {
8888 opts .Private = true
8989 opts .AllLimited = true
9090 }
91+
9192 issueCount := 0
9293 for page := 1 ; ; page ++ {
9394 opts .Page = page
@@ -127,15 +128,6 @@ func SearchIssues(ctx *context.APIContext) {
127128 issueIDs , err = issue_indexer .SearchIssuesByKeyword (repoIDs , keyword )
128129 }
129130
130- labels := ctx .Query ("labels" )
131- if splitted := strings .Split (labels , "," ); labels != "" && len (splitted ) > 0 {
132- labelIDs , err = models .GetLabelIDsInReposByNames (repoIDs , splitted )
133- if err != nil {
134- ctx .Error (http .StatusInternalServerError , "GetLabelIDsInRepoByNames" , err )
135- return
136- }
137- }
138-
139131 var isPull util.OptionalBool
140132 switch ctx .Query ("type" ) {
141133 case "pulls" :
@@ -146,6 +138,12 @@ func SearchIssues(ctx *context.APIContext) {
146138 isPull = util .OptionalBoolNone
147139 }
148140
141+ labels := strings .TrimSpace (ctx .Query ("labels" ))
142+ var includedLabelNames []string
143+ if len (labels ) > 0 {
144+ includedLabelNames = strings .Split (labels , "," )
145+ }
146+
149147 // Only fetch the issues if we either don't have a keyword or the search returned issues
150148 // This would otherwise return all issues if no issues were found by the search.
151149 if len (keyword ) == 0 || len (issueIDs ) > 0 || len (labelIDs ) > 0 {
@@ -154,13 +152,13 @@ func SearchIssues(ctx *context.APIContext) {
154152 Page : ctx .QueryInt ("page" ),
155153 PageSize : setting .UI .IssuePagingNum ,
156154 },
157- RepoIDs : repoIDs ,
158- IsClosed : isClosed ,
159- IssueIDs : issueIDs ,
160- LabelIDs : labelIDs ,
161- SortType : "priorityrepo" ,
162- PriorityRepoID : ctx .QueryInt64 ("priority_repo_id" ),
163- IsPull : isPull ,
155+ RepoIDs : repoIDs ,
156+ IsClosed : isClosed ,
157+ IssueIDs : issueIDs ,
158+ IncludedLabelNames : includedLabelNames ,
159+ SortType : "priorityrepo" ,
160+ PriorityRepoID : ctx .QueryInt64 ("priority_repo_id" ),
161+ IsPull : isPull ,
164162 })
165163 }
166164
0 commit comments