mirror of
https://github.com/go-gitea/gitea.git
synced 2024-09-01 14:56:30 +00:00
fix: make run index group by repo id only
This commit is contained in:
parent
a5a112425b
commit
a8f74d4ec8
@ -7,7 +7,6 @@ package bots
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash/fnv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.gitea.io/gitea/core"
|
"code.gitea.io/gitea/core"
|
||||||
@ -25,10 +24,10 @@ import (
|
|||||||
type Run struct {
|
type Run struct {
|
||||||
ID int64
|
ID int64
|
||||||
Title string
|
Title string
|
||||||
RepoID int64 `xorm:"index unique(repo_workflow_index)"`
|
RepoID int64 `xorm:"index unique(repo_index)"`
|
||||||
Repo *repo_model.Repository `xorm:"-"`
|
Repo *repo_model.Repository `xorm:"-"`
|
||||||
WorkflowID string `xorm:"index unique(repo_workflow_index)"` // the name of workflow file
|
WorkflowID string `xorm:"index"` // the name of workflow file
|
||||||
Index int64 `xorm:"index unique(repo_workflow_index)"` // a unique number for each run of a particular workflow in a repository
|
Index int64 `xorm:"index unique(repo_index)"` // a unique number for each run of a repository
|
||||||
TriggerUserID int64
|
TriggerUserID int64
|
||||||
TriggerUser *user_model.User `xorm:"-"`
|
TriggerUser *user_model.User `xorm:"-"`
|
||||||
Ref string
|
Ref string
|
||||||
@ -115,15 +114,7 @@ func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) err
|
|||||||
|
|
||||||
// InsertRun inserts a bot run
|
// InsertRun inserts a bot run
|
||||||
func InsertRun(run *Run, jobs []*jobparser.SingleWorkflow) error {
|
func InsertRun(run *Run, jobs []*jobparser.SingleWorkflow) error {
|
||||||
var groupID int64
|
index, err := db.GetNextResourceIndex("bots_run_index", run.RepoID)
|
||||||
{
|
|
||||||
// tricky way to get resource group id
|
|
||||||
h := fnv.New64()
|
|
||||||
_, _ = h.Write([]byte(fmt.Sprintf("%d_%s", run.RepoID, run.WorkflowID)))
|
|
||||||
groupID = int64(h.Sum64())
|
|
||||||
}
|
|
||||||
|
|
||||||
index, err := db.GetNextResourceIndex("bots_run_index", groupID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,9 @@ func addBotTables(x *xorm.Engine) error {
|
|||||||
type BotsRun struct {
|
type BotsRun struct {
|
||||||
ID int64
|
ID int64
|
||||||
Title string
|
Title string
|
||||||
RepoID int64 `xorm:"index unique(repo_workflow_index)"`
|
RepoID int64 `xorm:"index unique(repo_index)"`
|
||||||
WorkflowID string `xorm:"index unique(repo_workflow_index)"` // the name of workflow file
|
WorkflowID string `xorm:"index"` // the name of workflow file
|
||||||
Index int64 `xorm:"index unique(repo_workflow_index)"` // a unique number for each run of a particular workflow in a repository
|
Index int64 `xorm:"index unique(repo_index)"` // a unique number for each run of a repository
|
||||||
TriggerUserID int64
|
TriggerUserID int64
|
||||||
Ref string
|
Ref string
|
||||||
CommitSHA string
|
CommitSHA string
|
||||||
|
Loading…
Reference in New Issue
Block a user