From 2205ac9b5819495fb98fea83786369390695bd31 Mon Sep 17 00:00:00 2001 From: mr Date: Thu, 23 Jan 2025 11:35:35 +0100 Subject: [PATCH] light modification --- models/workflow_execution/workflow_execution.go | 2 +- .../workflow_execution/workflow_execution_mongo_accessor.go | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/models/workflow_execution/workflow_execution.go b/models/workflow_execution/workflow_execution.go index d21d756..a64f4ac 100644 --- a/models/workflow_execution/workflow_execution.go +++ b/models/workflow_execution/workflow_execution.go @@ -23,7 +23,7 @@ type WorkflowExecutions struct { utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name) ExecDate time.Time `json:"execution_date,omitempty" bson:"execution_date,omitempty" validate:"required"` // ExecDate is the execution date of the workflow, is required EndDate *time.Time `json:"end_date,omitempty" bson:"end_date,omitempty"` // EndDate is the end date of the workflow - State enum.BookingStatus `json:"state" bson:"state" default:"0"` // State is the state of the workflow + State enum.BookingStatus `json:"state" bson:"state" default:"1"` // State is the state of the workflow WorkflowID string `json:"workflow_id" bson:"workflow_id,omitempty"` // WorkflowID is the ID of the workflow } diff --git a/models/workflow_execution/workflow_execution_mongo_accessor.go b/models/workflow_execution/workflow_execution_mongo_accessor.go index 8ccb546..25fad88 100644 --- a/models/workflow_execution/workflow_execution_mongo_accessor.go +++ b/models/workflow_execution/workflow_execution_mongo_accessor.go @@ -2,7 +2,6 @@ package workflow_execution import ( "errors" - "fmt" "time" "cloud.o-forge.io/core/oc-lib/dbs" @@ -58,7 +57,7 @@ func (wfa *workflowExecutionMongoAccessor) CopyOne(data utils.DBObject) (utils.D func (a *workflowExecutionMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) { return utils.GenericLoadOne[*WorkflowExecutions](id, func(d utils.DBObject) (utils.DBObject, int, error) { if d.(*WorkflowExecutions).State == enum.DRAFT && !a.shallow && time.Now().UTC().After(d.(*WorkflowExecutions).ExecDate) { - utils.GenericDeleteOne(d.GetID(), newShallowAccessor(a.Request)) + utils.GenericDeleteOne(d.GetID(), a) return nil, 404, errors.New("not found") } if d.(*WorkflowExecutions).State == enum.SCHEDULED && !a.shallow && time.Now().UTC().After(d.(*WorkflowExecutions).ExecDate) { @@ -79,9 +78,8 @@ func (a *workflowExecutionMongoAccessor) Search(filters *dbs.Filters, search str func (a *workflowExecutionMongoAccessor) getExec() func(utils.DBObject) utils.ShallowDBObject { return func(d utils.DBObject) utils.ShallowDBObject { - fmt.Println("getExec", d) if d.(*WorkflowExecutions).State == enum.DRAFT && time.Now().UTC().After(d.(*WorkflowExecutions).ExecDate) { - utils.GenericDeleteOne(d.GetID(), newShallowAccessor(a.Request)) + utils.GenericDeleteOne(d.GetID(), a) return nil } if d.(*WorkflowExecutions).State == enum.SCHEDULED && time.Now().UTC().After(d.(*WorkflowExecutions).ExecDate) {