feat(api): add sort parameter to list issues API (#7211)
- Add the `sort` parameter to the `/api/v1/{repo}/{owner}/issues` API endpoint. Default behavior is preserved. - Resolves forgejo/forgejo#4173 - Add (non-exhaustive) integration testing. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7211 Reviewed-by: Otto <otto@codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
parent
a624b6a8f4
commit
7d6d4f94ee
4 changed files with 97 additions and 1 deletions
|
@ -397,6 +397,12 @@ func ListIssues(ctx *context.APIContext) {
|
|||
// in: query
|
||||
// description: page size of results
|
||||
// type: integer
|
||||
// - 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"
|
||||
|
@ -510,7 +516,7 @@ func ListIssues(ctx *context.APIContext) {
|
|||
RepoIDs: []int64{ctx.Repo.Repository.ID},
|
||||
IsPull: isPull,
|
||||
IsClosed: isClosed,
|
||||
SortBy: issue_indexer.SortByCreatedDesc,
|
||||
SortBy: issue_indexer.ParseSortBy(ctx.FormString("sort"), issue_indexer.SortByCreatedDesc),
|
||||
}
|
||||
if since != 0 {
|
||||
searchOpt.UpdatedAfterUnix = optional.Some(since)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue