mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
2978 files. The fork is 2026-07-15 (rebrand: gitea.dev -> github.com/hanzoai/git), so 2026 is the year, and "Copyright 2026 Hanzo AI, Inc." was already the form used by the handful of files that had ours. Shape is now: // Copyright 2026 Hanzo AI, Inc. All rights reserved. // Copyright 2015 The Gogs Authors. All rights reserved. // Copyright 2019 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT Ours on top, theirs retained verbatim. Retained because MIT requires it, and separately because they are true — those authors did write that code. Not renamed to "The Git Authors": Git is a different project under a different license, and putting its name here would attribute this code to people who have nothing to do with it. Adding our line is the fix; overwriting theirs would have been both a licence violation and a false statement. gofmt still reports import-order drift in some of these files. It predates this change (verified against a stash) and is left alone rather than burying a one-line-per-file legal change under 3000 files of unrelated reordering. Build clean. Co-authored-by: Hanzo Dev <[email protected]>
88 lines
2.1 KiB
Go
88 lines
2.1 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package admin
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/hanzoai/git/modules/log"
|
|
"github.com/hanzoai/git/modules/structs"
|
|
"github.com/hanzoai/git/modules/util"
|
|
"github.com/hanzoai/git/routers/api/v1/utils"
|
|
"github.com/hanzoai/git/services/context"
|
|
"github.com/hanzoai/git/services/cron"
|
|
)
|
|
|
|
// ListCronTasks api for getting cron tasks
|
|
func ListCronTasks(ctx *context.APIContext) {
|
|
// swagger:operation GET /admin/cron admin adminCronList
|
|
// ---
|
|
// summary: List cron tasks
|
|
// produces:
|
|
// - application/json
|
|
// parameters:
|
|
// - 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/CronList"
|
|
// "403":
|
|
// "$ref": "#/responses/forbidden"
|
|
tasks := cron.ListTasks()
|
|
count := len(tasks)
|
|
|
|
listOpts := utils.GetListOptions(ctx)
|
|
tasks = util.PaginateSlice(tasks, listOpts.Page, listOpts.PageSize).(cron.TaskTable)
|
|
|
|
res := make([]structs.Cron, len(tasks))
|
|
for i, task := range tasks {
|
|
res[i] = structs.Cron{
|
|
Name: task.Name,
|
|
Schedule: task.Spec,
|
|
Next: task.Next,
|
|
Prev: task.Prev,
|
|
ExecTimes: task.ExecTimes,
|
|
}
|
|
}
|
|
|
|
ctx.SetTotalCountHeader(int64(count))
|
|
ctx.JSON(http.StatusOK, res)
|
|
}
|
|
|
|
// PostCronTask api for getting cron tasks
|
|
func PostCronTask(ctx *context.APIContext) {
|
|
// swagger:operation POST /admin/cron/{task} admin adminCronRun
|
|
// ---
|
|
// summary: Run cron task
|
|
// produces:
|
|
// - application/json
|
|
// parameters:
|
|
// - name: task
|
|
// in: path
|
|
// description: task to run
|
|
// type: string
|
|
// required: true
|
|
// responses:
|
|
// "204":
|
|
// "$ref": "#/responses/empty"
|
|
// "404":
|
|
// "$ref": "#/responses/notFound"
|
|
task := cron.GetTask(ctx.PathParam("task"))
|
|
if task == nil {
|
|
ctx.APIErrorNotFound()
|
|
return
|
|
}
|
|
task.Run()
|
|
log.Trace("Cron Task %s started by admin(%s)", task.Name, ctx.Doer.Name)
|
|
|
|
ctx.Status(http.StatusNoContent)
|
|
}
|