workflow execution evolved
This commit is contained in:
parent
88b7cfe2fd
commit
e646cfef0b
@ -46,6 +46,9 @@ func (a *bookingMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject, int
|
|||||||
|
|
||||||
func (a *bookingMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
func (a *bookingMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
||||||
return utils.GenericLoadOne[*Booking](id, func(d utils.DBObject) (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 {
|
if (d.(*Booking).ExpectedEndDate) == nil {
|
||||||
d.(*Booking).State = enum.FORGOTTEN
|
d.(*Booking).State = enum.FORGOTTEN
|
||||||
utils.GenericRawUpdateOne(d, id, a)
|
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 {
|
func (a *bookingMongoAccessor) getExec() func(utils.DBObject) utils.ShallowDBObject {
|
||||||
return func(d 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) {
|
if d.(*Booking).State == enum.SCHEDULED && time.Now().UTC().After(*&d.(*Booking).ExpectedStartDate) {
|
||||||
d.(*Booking).State = enum.DELAYED
|
d.(*Booking).State = enum.DELAYED
|
||||||
utils.GenericRawUpdateOne(d, d.GetID(), a)
|
utils.GenericRawUpdateOne(d, d.GetID(), a)
|
||||||
|
@ -28,9 +28,8 @@ type WorkflowExecutions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *WorkflowExecutions) StoreDraftDefault() {
|
func (r *WorkflowExecutions) StoreDraftDefault() {
|
||||||
// r.IsDraft = true
|
r.IsDraft = true // TODO: TEMPORARY
|
||||||
r.IsDraft = false // TODO: TEMPORARY
|
r.State = enum.DRAFT
|
||||||
r.State = enum.SCHEDULED
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *WorkflowExecutions) CanUpdate(set utils.DBObject) (bool, utils.DBObject) {
|
func (r *WorkflowExecutions) CanUpdate(set utils.DBObject) (bool, utils.DBObject) {
|
||||||
|
Loading…
Reference in New Issue
Block a user