From bc79d54284bed00e0c846099854419cbe4b777c6 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 12 Nov 2024 11:01:47 +0100 Subject: [PATCH] set up --- models/workflow_execution/workflow_execution.go | 2 ++ .../workflow_execution/workflow_execution_mongo_accessor.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/models/workflow_execution/workflow_execution.go b/models/workflow_execution/workflow_execution.go index 50846f9..b4be771 100644 --- a/models/workflow_execution/workflow_execution.go +++ b/models/workflow_execution/workflow_execution.go @@ -18,6 +18,7 @@ const ( STARTED FAILURE SUCCESS + FORGOTTEN ) var str = [...]string{ @@ -25,6 +26,7 @@ var str = [...]string{ "started", "failure", "success", + "forgotten", } func FromInt(i int) string { diff --git a/models/workflow_execution/workflow_execution_mongo_accessor.go b/models/workflow_execution/workflow_execution_mongo_accessor.go index 31503d3..3a78ade 100644 --- a/models/workflow_execution/workflow_execution_mongo_accessor.go +++ b/models/workflow_execution/workflow_execution_mongo_accessor.go @@ -1,6 +1,8 @@ package workflow_execution import ( + "time" + "cloud.o-forge.io/core/oc-lib/dbs" "cloud.o-forge.io/core/oc-lib/dbs/mongo" "cloud.o-forge.io/core/oc-lib/models/utils" @@ -38,6 +40,10 @@ func (wfa *workflowExecutionMongoAccessor) LoadOne(id string) (utils.DBObject, i return nil, code, err } res_mongo.Decode(&workflow) + if workflow.State == int64(SCHEDULED) && time.Now().UTC().After(*workflow.ExecDate) { + workflow.State = int64(FORGOTTEN) + wfa.UpdateOne(&workflow, id) + } return &workflow, 200, nil }