workflow execution evolved
This commit is contained in:
@@ -46,6 +46,9 @@ func (a *bookingMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject, int
|
||||
|
||||
func (a *bookingMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
||||
return utils.GenericLoadOne[*Booking](id, func(d utils.DBObject) (utils.DBObject, int, error) {
|
||||
if d.(*Booking).State == enum.DRAFT && time.Now().UTC().After(d.(*Booking).ExpectedStartDate) {
|
||||
return utils.GenericDeleteOne(d.GetID(), a)
|
||||
}
|
||||
if (d.(*Booking).ExpectedEndDate) == nil {
|
||||
d.(*Booking).State = enum.FORGOTTEN
|
||||
utils.GenericRawUpdateOne(d, id, a)
|
||||
@@ -67,6 +70,10 @@ func (a *bookingMongoAccessor) Search(filters *dbs.Filters, search string, isDra
|
||||
|
||||
func (a *bookingMongoAccessor) getExec() func(utils.DBObject) utils.ShallowDBObject {
|
||||
return func(d utils.DBObject) utils.ShallowDBObject {
|
||||
if d.(*Booking).State == enum.DRAFT && time.Now().UTC().After(d.(*Booking).ExpectedStartDate) {
|
||||
utils.GenericDeleteOne(d.GetID(), a)
|
||||
return nil
|
||||
}
|
||||
if d.(*Booking).State == enum.SCHEDULED && time.Now().UTC().After(*&d.(*Booking).ExpectedStartDate) {
|
||||
d.(*Booking).State = enum.DELAYED
|
||||
utils.GenericRawUpdateOne(d, d.GetID(), a)
|
||||
|
Reference in New Issue
Block a user