mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-19 03:21:05 +00:00
Adds `sort` and `order` query parameters to all action job list API
endpoints (`/admin/actions/jobs`, `/repos/{owner}/{repo}/actions/jobs`,
`/repos/{owner}/{repo}/actions/runs/{run}/jobs`, `/user/actions/jobs`),
following the existing `OrderByMap` pattern used by repo/user search
endpoints.
- Default is `id` / `asc` (backwards compatible — matches previous DB
natural order)
- Only `id` sort field for now; the map is extensible for future fields
- Returns 422 for invalid sort/order values
- `ToOrders()` returns empty string when `OrderBy` is unset, so internal
callers (webhook dispatch, concurrency checks) are unaffected
Closes: #37666
Supersedes: #37667
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: silverwind <me@silverwind.io>
104 lines
2.6 KiB
Go
104 lines
2.6 KiB
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package admin
|
|
|
|
import (
|
|
"code.gitea.io/gitea/routers/api/v1/shared"
|
|
"code.gitea.io/gitea/services/context"
|
|
)
|
|
|
|
// ListWorkflowJobs Lists all jobs
|
|
func ListWorkflowJobs(ctx *context.APIContext) {
|
|
// swagger:operation GET /admin/actions/jobs admin listAdminWorkflowJobs
|
|
// ---
|
|
// summary: Lists all jobs
|
|
// produces:
|
|
// - application/json
|
|
// parameters:
|
|
// - name: status
|
|
// in: query
|
|
// description: workflow status (pending, queued, in_progress, failure, success, skipped)
|
|
// type: string
|
|
// required: false
|
|
// - name: page
|
|
// in: query
|
|
// description: page number of results to return (1-based)
|
|
// type: integer
|
|
// - name: limit
|
|
// in: query
|
|
// description: page size of results
|
|
// type: integer
|
|
// - name: sort
|
|
// in: query
|
|
// description: sort jobs by attribute. Supported values are "id". Default is "id"
|
|
// type: string
|
|
// - name: order
|
|
// in: query
|
|
// description: sort order, either "asc" (ascending) or "desc" (descending). Default is "asc"
|
|
// type: string
|
|
// responses:
|
|
// "200":
|
|
// "$ref": "#/responses/WorkflowJobsList"
|
|
// "400":
|
|
// "$ref": "#/responses/error"
|
|
// "404":
|
|
// "$ref": "#/responses/notFound"
|
|
// "422":
|
|
// "$ref": "#/responses/validationError"
|
|
|
|
shared.ListJobs(ctx, 0, 0, 0, nil)
|
|
}
|
|
|
|
// ListWorkflowRuns Lists all runs
|
|
func ListWorkflowRuns(ctx *context.APIContext) {
|
|
// swagger:operation GET /admin/actions/runs admin listAdminWorkflowRuns
|
|
// ---
|
|
// summary: Lists all runs
|
|
// produces:
|
|
// - application/json
|
|
// parameters:
|
|
// - name: event
|
|
// in: query
|
|
// description: workflow event name
|
|
// type: string
|
|
// required: false
|
|
// - name: branch
|
|
// in: query
|
|
// description: workflow branch
|
|
// type: string
|
|
// required: false
|
|
// - name: status
|
|
// in: query
|
|
// description: workflow status (pending, queued, in_progress, failure, success, skipped)
|
|
// type: string
|
|
// required: false
|
|
// - name: actor
|
|
// in: query
|
|
// description: triggered by user
|
|
// type: string
|
|
// required: false
|
|
// - name: head_sha
|
|
// in: query
|
|
// description: triggering sha of the workflow run
|
|
// type: string
|
|
// required: false
|
|
// - name: page
|
|
// in: query
|
|
// description: page number of results to return (1-based)
|
|
// type: integer
|
|
// - name: limit
|
|
// in: query
|
|
// description: page size of results
|
|
// type: integer
|
|
// responses:
|
|
// "200":
|
|
// "$ref": "#/responses/WorkflowRunsList"
|
|
// "400":
|
|
// "$ref": "#/responses/error"
|
|
// "404":
|
|
// "$ref": "#/responses/notFound"
|
|
|
|
shared.ListRuns(ctx, 0, 0)
|
|
}
|