mirror of
https://github.com/go-gitea/gitea
synced 2024-11-06 18:24:24 +00:00
70 lines
1.8 KiB
Go
70 lines
1.8 KiB
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package repo
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
actions_model "code.gitea.io/gitea/models/actions"
|
|
"code.gitea.io/gitea/models/db"
|
|
"code.gitea.io/gitea/modules/context"
|
|
api "code.gitea.io/gitea/modules/structs"
|
|
"code.gitea.io/gitea/services/convert"
|
|
)
|
|
|
|
// ListActionTasks list all the actions of a repository
|
|
func ListActionTasks(ctx *context.APIContext) {
|
|
// swagger:operation GET /repos/{owner}/{repo}/actions/tasks repository ListActionTasks
|
|
// ---
|
|
// summary: List a repository's action tasks
|
|
// produces:
|
|
// - application/json
|
|
// parameters:
|
|
// - name: owner
|
|
// in: path
|
|
// description: owner of the repo
|
|
// type: string
|
|
// required: true
|
|
// - name: repo
|
|
// in: path
|
|
// description: name of the repo
|
|
// type: string
|
|
// required: true
|
|
// - name: page
|
|
// in: query
|
|
// description: page number of results to return (1-based)
|
|
// type: integer
|
|
// - name: limit
|
|
// in: query
|
|
// description: page size of results, default maximum page size is 50
|
|
// type: integer
|
|
// responses:
|
|
// "200":
|
|
// "$ref": "#/responses/TasksList"
|
|
page := ctx.FormInt("page")
|
|
limit := convert.ToCorrectPageSize(ctx.FormInt("limit"))
|
|
|
|
opts := actions_model.FindTaskOptions{
|
|
RepoID: ctx.Repo.Repository.ID,
|
|
ListOptions: db.ListOptions{
|
|
Page: page,
|
|
PageSize: limit,
|
|
},
|
|
Status: actions_model.StatusUnknown, // Unknown means all
|
|
IDOrderDesc: true,
|
|
}
|
|
tasks, err := actions_model.FindTasks(ctx, opts)
|
|
if err != nil {
|
|
ctx.Error(http.StatusInternalServerError, "GetTags", err)
|
|
return
|
|
}
|
|
|
|
apiActionTasks := make([]*api.ActionTask, len(tasks))
|
|
for i := range tasks {
|
|
apiActionTasks[i] = convert.ToActionTask(ctx, ctx.Repo.Repository, tasks[i])
|
|
}
|
|
|
|
ctx.JSON(http.StatusOK, &apiActionTasks)
|
|
}
|