book in workflow
This commit is contained in:
parent
4688d9c681
commit
8dc009564a
@ -2,6 +2,7 @@ package oclib
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
@ -35,15 +36,28 @@ func (d *Workflow) GetName() string {
|
||||
}
|
||||
|
||||
func (d *Workflow) CheckBooking() bool {
|
||||
fmt.Println("CheckBooking", d.Schedule)
|
||||
if d.Schedule != nil && d.Schedule.Start != nil {
|
||||
sd := primitive.NewDateTimeFromTime(d.Schedule.Start.Add(time.Second * -10))
|
||||
ed := primitive.NewDateTimeFromTime(d.Schedule.Start.Add(time.Second * 10))
|
||||
f := dbs.Filters{
|
||||
And: map[string][]dbs.Filter{
|
||||
"execution_date": {{Operator: "gte", Value: sd}, {Operator: "lte", Value: ed}},
|
||||
},
|
||||
sd := primitive.NewDateTimeFromTime(d.Schedule.Start.Add(time.Minute * -1))
|
||||
var f dbs.Filters
|
||||
if d.Schedule.End == nil {
|
||||
ed := primitive.NewDateTimeFromTime(d.Schedule.Start.Add(time.Minute * 10))
|
||||
f = dbs.Filters{
|
||||
And: map[string][]dbs.Filter{
|
||||
"execution_date": {{Operator: "gte", Value: sd}, {Operator: "lte", Value: ed}},
|
||||
},
|
||||
}
|
||||
} else {
|
||||
ed := primitive.NewDateTimeFromTime(d.Schedule.End.Add(time.Minute * 1))
|
||||
f = dbs.Filters{
|
||||
And: map[string][]dbs.Filter{
|
||||
"execution_date": {{Operator: "gte", Value: sd}},
|
||||
"end_date": {{Operator: "lte", Value: ed}},
|
||||
},
|
||||
}
|
||||
}
|
||||
res, _, _ := d.GetAccessor().Search(&f, "")
|
||||
res, code, err := d.GetAccessor().Search(&f, "")
|
||||
fmt.Println("res", res, f, code, err)
|
||||
return len(res) == 0
|
||||
}
|
||||
return true
|
||||
|
Loading…
Reference in New Issue
Block a user