Booking trace API

This commit is contained in:
mr
2024-08-21 14:07:22 +02:00
parent f64563c9ff
commit ddb4f76af7
3 changed files with 91 additions and 24 deletions

View File

@@ -18,7 +18,7 @@ import (
type AbstractWorkflow struct {
resources.ResourceSet
Graph *graph.Graph `bson:"graph,omitempty" json:"graph,omitempty"`
ScheduleActive bool `bson:"schedule_active,omitempty" json:"schedule_active,omitempty"`
ScheduleActive bool `json:"schedule_active,omitempty" bson:"schedule_active,omitempty"`
Schedule *WorkflowSchedule `bson:"schedule,omitempty" json:"schedule,omitempty"`
Shared []string `json:"shared,omitempty" bson:"shared,omitempty"`
}

View File

@@ -80,7 +80,7 @@ func (wfa *workflowMongoAccessor) getExecutions(id string, data *Workflow) ([]*w
func (wfa *workflowMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) {
wfa.execution(id, &Workflow{
AbstractWorkflow: AbstractWorkflow{ScheduleActive: false},
AbstractWorkflow: AbstractWorkflow{ScheduleActive: true},
}, true)
return wfa.GenericDeleteOne(id, wfa)
}
@@ -138,13 +138,16 @@ func (wfa *workflowMongoAccessor) book(id string, realData *Workflow, execs []*w
}
func (wfa *workflowMongoAccessor) execution(id string, realData *Workflow, delete bool) (int, error) {
if !realData.ScheduleActive {
return 200, nil
}
var err error
nats := tools.NewNATSCaller()
res, code, _ := wfa.LoadOne(id)
if code != 200 {
return 404, errors.New("could not load workflow")
}
if (realData.Schedule == nil && !realData.ScheduleActive) || (realData.Schedule == nil && realData.ScheduleActive) {
if realData.Schedule == nil && realData.ScheduleActive {
mongo.MONGOService.DeleteMultiple(map[string]interface{}{
"state": 1,
"workflow_id": id,