feat(be): disable refs for schedules

This commit is contained in:
Denis Gukov 2024-11-26 06:56:54 +00:00
parent 8123bdad21
commit 5fc7b48d93
2 changed files with 24 additions and 16 deletions

View File

@ -54,6 +54,8 @@ type ObjectReferrers struct {
Templates []ObjectReferrer `json:"templates"` Templates []ObjectReferrer `json:"templates"`
Inventories []ObjectReferrer `json:"inventories"` Inventories []ObjectReferrer `json:"inventories"`
Repositories []ObjectReferrer `json:"repositories"` Repositories []ObjectReferrer `json:"repositories"`
Integrations []ObjectReferrer `json:"integrations"`
Schedules []ObjectReferrer `json:"schedules"`
} }
type IntegrationReferrers struct { type IntegrationReferrers struct {

View File

@ -4,14 +4,15 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/semaphoreui/semaphore/db"
"github.com/semaphoreui/semaphore/util"
"go.etcd.io/bbolt"
"reflect" "reflect"
"sort" "sort"
"strings" "strings"
"sync" "sync"
"time" "time"
"github.com/semaphoreui/semaphore/db"
"github.com/semaphoreui/semaphore/util"
"go.etcd.io/bbolt"
) )
const MaxID = 2147483647 const MaxID = 2147483647
@ -689,20 +690,25 @@ func (d *BoltDb) getObjectRefs(projectID int, objectProps db.ObjectProps, object
return return
} }
templates, err := d.getObjectRefsFrom(projectID, objectProps, intObjectID(objectID), db.ScheduleProps) // templates, err := d.getObjectRefsFrom(projectID, objectProps, intObjectID(objectID), db.ScheduleProps)
for _, st := range templates { // for _, st := range templates {
exists := false // exists := false
for _, tpl := range refs.Templates { // for _, tpl := range refs.Templates {
if tpl.ID == st.ID { // if tpl.ID == st.ID {
exists = true // exists = true
break // break
} // }
} // }
if exists { // if exists {
continue // continue
} // }
refs.Templates = append(refs.Templates, st) // refs.Templates = append(refs.Templates, st)
// }
refs.Integrations, err = d.getObjectRefsFrom(projectID, objectProps, intObjectID(objectID), db.IntegrationProps)
if err != nil {
return
} }
return return