1
1
mirror of https://github.com/go-gitea/gitea synced 2025-09-28 03:28:13 +00:00

Add builds UI

This commit is contained in:
Lunny Xiao
2022-05-03 16:03:24 +08:00
committed by Jason Song
parent 7732392a96
commit 5a479bb034
23 changed files with 599 additions and 50 deletions

37
models/bots/task_list.go Normal file
View File

@@ -0,0 +1,37 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package bots
import (
"code.gitea.io/gitea/models/db"
user_model "code.gitea.io/gitea/models/user"
)
type TaskList []*Task
// GetUserIDs returns a slice of user's id
func (tasks TaskList) GetUserIDs() []int64 {
userIDsMap := make(map[int64]struct{})
for _, task := range tasks {
userIDsMap[task.TriggerUserID] = struct{}{}
}
userIDs := make([]int64, 0, len(userIDsMap))
for userID := range userIDsMap {
userIDs = append(userIDs, userID)
}
return userIDs
}
func (tasks TaskList) LoadTriggerUser() error {
userIDs := tasks.GetUserIDs()
users := make(map[int64]*user_model.User, len(userIDs))
if err := db.GetEngine(db.DefaultContext).In("id", userIDs).Find(&users); err != nil {
return err
}
for _, task := range tasks {
task.TriggerUser = users[task.TriggerUserID]
}
return nil
}