fixing cron dependancies
This commit is contained in:
parent
14f585c657
commit
5ac4492369
@ -3,7 +3,6 @@ package oclib
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/dbs"
|
||||
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
|
||||
@ -12,7 +11,6 @@ import (
|
||||
"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
|
||||
"cloud.o-forge.io/core/oc-lib/models/workspace"
|
||||
cron "github.com/robfig/cron/v3"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type workflowMongoAccessor struct {
|
||||
@ -23,21 +21,6 @@ func New() *workflowMongoAccessor {
|
||||
return &workflowMongoAccessor{}
|
||||
}
|
||||
|
||||
func (wfa *workflowMongoAccessor) CheckBooking(start *time.Time) bool {
|
||||
accessor := (&workflow_execution.WorkflowExecution{}).GetAccessor()
|
||||
s := start.Add(time.Duration(-10) * time.Second)
|
||||
e := start.Add(time.Duration(10) * time.Second)
|
||||
sd := primitive.NewDateTimeFromTime(s)
|
||||
ed := primitive.NewDateTimeFromTime(e)
|
||||
f := dbs.Filters{
|
||||
And: map[string][]dbs.Filter{
|
||||
"execution_date": {{Operator: "gte", Value: sd}, {Operator: "lte", Value: ed}},
|
||||
},
|
||||
}
|
||||
arr, _, _ := accessor.Search(&f, "")
|
||||
return len(arr) == 0
|
||||
}
|
||||
|
||||
func (wfa *workflowMongoAccessor) getExecutions(id string, data *Workflow) ([]*workflow_execution.WorkflowExecution, error) {
|
||||
workflows_execution := []*workflow_execution.WorkflowExecution{}
|
||||
if data.Schedule != nil {
|
||||
@ -104,7 +87,7 @@ func (wfa *workflowMongoAccessor) execution(id string, realData *Workflow, delet
|
||||
if r.Schedule.Start == realData.Schedule.Start && r.Schedule.End == realData.Schedule.End && r.Schedule.Cron == realData.Schedule.Cron {
|
||||
return 200, nil
|
||||
}
|
||||
if !wfa.CheckBooking(realData.Schedule.Start) {
|
||||
if !realData.CheckBooking(realData.Schedule.Start) {
|
||||
return 409, errors.New("the booking is already taken.")
|
||||
}
|
||||
if delete {
|
||||
|
Loading…
Reference in New Issue
Block a user