light modification

This commit is contained in:
mr 2025-01-23 11:35:35 +01:00
parent e9017767d1
commit 2205ac9b58
2 changed files with 3 additions and 5 deletions

View File

@ -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
}

View File

@ -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) {