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"`
Inventories []ObjectReferrer `json:"inventories"`
Repositories []ObjectReferrer `json:"repositories"`
Integrations []ObjectReferrer `json:"integrations"`
Schedules []ObjectReferrer `json:"schedules"`
}
type IntegrationReferrers struct {

View File

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