state execution

This commit is contained in:
mr 2024-11-12 11:41:57 +01:00
parent bc79d54284
commit d6dba8e1f1
2 changed files with 3 additions and 1 deletions

View File

@ -83,7 +83,7 @@ type WorkflowExecution struct {
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name) 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 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 EndDate *time.Time `json:"end_date,omitempty" bson:"end_date,omitempty"` // EndDate is the end date of the workflow
State int64 `json:"state,omitempty" bson:"state,omitempty"` // State is the state of the workflow State int64 `json:"state" bson:"state" default:"0"` // State is the state of the workflow
WorkflowID string `json:"workflow_id" bson:"workflow_id,omitempty"` // WorkflowID is the ID of the workflow WorkflowID string `json:"workflow_id" bson:"workflow_id,omitempty"` // WorkflowID is the ID of the workflow
} }

View File

@ -1,6 +1,7 @@
package workflow_execution package workflow_execution
import ( import (
"fmt"
"time" "time"
"cloud.o-forge.io/core/oc-lib/dbs" "cloud.o-forge.io/core/oc-lib/dbs"
@ -40,6 +41,7 @@ func (wfa *workflowExecutionMongoAccessor) LoadOne(id string) (utils.DBObject, i
return nil, code, err return nil, code, err
} }
res_mongo.Decode(&workflow) res_mongo.Decode(&workflow)
fmt.Println("workflow: ", workflow.State, time.Now().UTC().After(*workflow.ExecDate))
if workflow.State == int64(SCHEDULED) && time.Now().UTC().After(*workflow.ExecDate) { if workflow.State == int64(SCHEDULED) && time.Now().UTC().After(*workflow.ExecDate) {
workflow.State = int64(FORGOTTEN) workflow.State = int64(FORGOTTEN)
wfa.UpdateOne(&workflow, id) wfa.UpdateOne(&workflow, id)