mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-10-22 20:36:09 +00:00
Add queue details UI for admins (#1632)
# Changes - Adds an admin view to see the whole work-queue of the server. - The admin can also pause / resume the queue. - The view is reloading data every 5 seconds automatically. - The task model from queue got removed in favor of the one from models.
This commit is contained in:
@@ -28,18 +28,7 @@ import (
|
||||
// ensures the task Queue can be restored when the system starts.
|
||||
func WithTaskStore(q Queue, s model.TaskStore) Queue {
|
||||
tasks, _ := s.TaskList()
|
||||
var toEnqueue []*Task
|
||||
for _, task := range tasks {
|
||||
toEnqueue = append(toEnqueue, &Task{
|
||||
ID: task.ID,
|
||||
Data: task.Data,
|
||||
Labels: task.Labels,
|
||||
Dependencies: task.Dependencies,
|
||||
RunOn: task.RunOn,
|
||||
DepStatus: task.DepStatus,
|
||||
})
|
||||
}
|
||||
if err := q.PushAtOnce(context.Background(), toEnqueue); err != nil {
|
||||
if err := q.PushAtOnce(context.Background(), tasks); err != nil {
|
||||
log.Error().Err(err).Msg("PushAtOnce failed")
|
||||
}
|
||||
return &persistentQueue{q, s}
|
||||
@@ -51,15 +40,8 @@ type persistentQueue struct {
|
||||
}
|
||||
|
||||
// Push pushes a task to the tail of this queue.
|
||||
func (q *persistentQueue) Push(c context.Context, task *Task) error {
|
||||
if err := q.store.TaskInsert(&model.Task{
|
||||
ID: task.ID,
|
||||
Data: task.Data,
|
||||
Labels: task.Labels,
|
||||
Dependencies: task.Dependencies,
|
||||
RunOn: task.RunOn,
|
||||
DepStatus: task.DepStatus,
|
||||
}); err != nil {
|
||||
func (q *persistentQueue) Push(c context.Context, task *model.Task) error {
|
||||
if err := q.store.TaskInsert(task); err != nil {
|
||||
return err
|
||||
}
|
||||
err := q.Queue.Push(c, task)
|
||||
@@ -72,17 +54,10 @@ func (q *persistentQueue) Push(c context.Context, task *Task) error {
|
||||
}
|
||||
|
||||
// PushAtOnce pushes multiple tasks to the tail of this queue.
|
||||
func (q *persistentQueue) PushAtOnce(c context.Context, tasks []*Task) error {
|
||||
func (q *persistentQueue) PushAtOnce(c context.Context, tasks []*model.Task) error {
|
||||
// TODO: invent store.NewSession who return context including a session and make TaskInsert & TaskDelete use it
|
||||
for _, task := range tasks {
|
||||
if err := q.store.TaskInsert(&model.Task{
|
||||
ID: task.ID,
|
||||
Data: task.Data,
|
||||
Labels: task.Labels,
|
||||
Dependencies: task.Dependencies,
|
||||
RunOn: task.RunOn,
|
||||
DepStatus: task.DepStatus,
|
||||
}); err != nil {
|
||||
if err := q.store.TaskInsert(task); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -98,7 +73,7 @@ func (q *persistentQueue) PushAtOnce(c context.Context, tasks []*Task) error {
|
||||
}
|
||||
|
||||
// Poll retrieves and removes a task head of this queue.
|
||||
func (q *persistentQueue) Poll(c context.Context, f FilterFn) (*Task, error) {
|
||||
func (q *persistentQueue) Poll(c context.Context, f FilterFn) (*model.Task, error) {
|
||||
task, err := q.Queue.Poll(c, f)
|
||||
if task != nil {
|
||||
log.Debug().Msgf("pull queue item: %s: remove from backup", task.ID)
|
||||
|
Reference in New Issue
Block a user