Adapt to new inputs env struct + instance of a resource
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
"cloud.o-forge.io/core/oc-lib/dbs"
|
||||
"cloud.o-forge.io/core/oc-lib/models/common/enum"
|
||||
"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
"github.com/nats-io/nats.go"
|
||||
@@ -37,6 +38,7 @@ func (sb *ScheduledBooking) AddSchedules(new_bookings []*workflow_execution.Work
|
||||
Bookings.Mu.Lock()
|
||||
defer Bookings.Mu.Unlock()
|
||||
for _, exec := range new_bookings {
|
||||
fmt.Println("Adding "+exec.UUID, !sb.execIsSet(exec))
|
||||
if !sb.execIsSet(exec) {
|
||||
sb.Bookings = append(sb.Bookings, exec)
|
||||
}
|
||||
@@ -122,7 +124,7 @@ func (s *ScheduleManager) getExecution(from time.Time, to time.Time) (exec_list
|
||||
f := dbs.Filters{
|
||||
And: map[string][]dbs.Filter{
|
||||
"execution_date": {{Operator: dbs.GTE.String(), Value: primitive.NewDateTimeFromTime(from)}, {Operator: dbs.LTE.String(), Value: primitive.NewDateTimeFromTime(to)}},
|
||||
"state": {{Operator: dbs.EQUAL.String(), Value: 1}},
|
||||
"state": {{Operator: dbs.EQUAL.String(), Value: enum.SCHEDULED}},
|
||||
},
|
||||
}
|
||||
res := oclib.NewRequest(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION), "", "", []string{}, nil).Search(&f, "", false)
|
||||
@@ -133,11 +135,16 @@ func (s *ScheduleManager) getExecution(from time.Time, to time.Time) (exec_list
|
||||
for _, exec := range res.Data {
|
||||
exec_list = append(exec_list, exec.(*workflow_execution.WorkflowExecutions))
|
||||
}
|
||||
fmt.Println("Found "+fmt.Sprintf("%v", len(exec_list))+" workflows", res)
|
||||
return
|
||||
}
|
||||
|
||||
func (s *ScheduleManager) getNextScheduledWorkflows(minutes float64) {
|
||||
start := time.Now().UTC()
|
||||
fmt.Println(s.getExecution(
|
||||
start.Add(time.Second*time.Duration(-1)).UTC(),
|
||||
start.Add(time.Minute*time.Duration(minutes)).UTC(),
|
||||
))
|
||||
if next_wf_exec, err := s.getExecution(
|
||||
start.Add(time.Second*time.Duration(-1)).UTC(),
|
||||
start.Add(time.Minute*time.Duration(minutes)).UTC(),
|
||||
|
||||
Reference in New Issue
Block a user