mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-03 00:45:22 +02:00
feat: show more relevant results for 'dependencies' dropdown (#8003)
- Fix issue dropdown breaking when currently selected issue is included in results. - Add `sort` parameter to `/issues/search` API. - Sort dropdown by relevance. - Make priority_repo_id work again. - Added E2E test. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8003 Reviewed-by: Shiny Nematoda <snematoda@noreply.codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Danko Aleksejevs <danko@very.lv> Co-committed-by: Danko Aleksejevs <danko@very.lv>
This commit is contained in:
parent
414199fc66
commit
184e068f37
17 changed files with 269 additions and 41 deletions
|
@ -121,6 +121,12 @@ func SearchIssues(ctx *context.APIContext) {
|
|||
// description: Number of items per page
|
||||
// type: integer
|
||||
// minimum: 0
|
||||
// - name: sort
|
||||
// in: query
|
||||
// description: Type of sort
|
||||
// type: string
|
||||
// enum: [relevance, latest, oldest, recentupdate, leastupdate, mostcomment, leastcomment, nearduedate, farduedate]
|
||||
// default: latest
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/IssueList"
|
||||
|
@ -276,7 +282,7 @@ func SearchIssues(ctx *context.APIContext) {
|
|||
IsClosed: isClosed,
|
||||
IncludedAnyLabelIDs: includedAnyLabels,
|
||||
MilestoneIDs: includedMilestones,
|
||||
SortBy: issue_indexer.SortByCreatedDesc,
|
||||
SortBy: issue_indexer.ParseSortBy(ctx.FormString("sort"), issue_indexer.SortByCreatedDesc),
|
||||
}
|
||||
|
||||
if since != 0 {
|
||||
|
@ -305,9 +311,10 @@ func SearchIssues(ctx *context.APIContext) {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: It's unsupported to sort by priority repo when searching by indexer,
|
||||
// it's indeed an regression, but I think it is worth to support filtering by indexer first.
|
||||
_ = ctx.FormInt64("priority_repo_id")
|
||||
priorityRepoID := ctx.FormInt64("priority_repo_id")
|
||||
if priorityRepoID > 0 {
|
||||
searchOpt.PriorityRepoID = optional.Some(priorityRepoID)
|
||||
}
|
||||
|
||||
ids, total, err := issue_indexer.SearchIssues(ctx, searchOpt)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue