mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 10:48:37 +00:00
Use GetListOptions() and panic()
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
actions_model "code.gitea.io/gitea/models/actions"
|
actions_model "code.gitea.io/gitea/models/actions"
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/routers/api/v1/utils"
|
||||||
"code.gitea.io/gitea/services/context"
|
"code.gitea.io/gitea/services/context"
|
||||||
"code.gitea.io/gitea/services/convert"
|
"code.gitea.io/gitea/services/convert"
|
||||||
)
|
)
|
||||||
@@ -52,18 +53,7 @@ func ListActionTasks(ctx *context.APIContext) {
|
|||||||
// "$ref": "#/responses/error"
|
// "$ref": "#/responses/error"
|
||||||
// "422":
|
// "422":
|
||||||
// "$ref": "#/responses/validationError"
|
// "$ref": "#/responses/validationError"
|
||||||
page := ctx.FormInt("page")
|
opts := utils.GetListOptions(ctx)
|
||||||
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, total, err := db.FindAndCount[actions_model.ActionTask](ctx, opts)
|
tasks, total, err := db.FindAndCount[actions_model.ActionTask](ctx, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -183,7 +183,7 @@ func ToTag(repo *repo_model.Repository, t *git.Tag) *api.Tag {
|
|||||||
// ToActionTask convert a actions_model.ActionTask to an api.ActionTask
|
// ToActionTask convert a actions_model.ActionTask to an api.ActionTask
|
||||||
func ToActionTask(ctx context.Context, repo *repo_model.Repository, t *actions_model.ActionTask) *api.ActionTask {
|
func ToActionTask(ctx context.Context, repo *repo_model.Repository, t *actions_model.ActionTask) *api.ActionTask {
|
||||||
if err := t.LoadAttributes(ctx); err != nil {
|
if err := t.LoadAttributes(ctx); err != nil {
|
||||||
log.Warn("LoadAttributes of ActionTask: %v", err)
|
panic(fmt.Sprintf("failed to execute ActionTask.LoadAttributes(): %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
return &api.ActionTask{
|
return &api.ActionTask{
|
||||||
|
Reference in New Issue
Block a user