From c7c1535ba91ad7ce88111d44f81fbcd688230566 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 12 Feb 2025 16:08:15 +0100 Subject: [PATCH] workflow scheduler create booking with a booking execution lot id --- models/common/planner.go | 2 +- .../workflow_execution/workflow_execution.go | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/models/common/planner.go b/models/common/planner.go index fac93c3..066d5a3 100644 --- a/models/common/planner.go +++ b/models/common/planner.go @@ -23,7 +23,7 @@ func GetPlannerNearestStart(start time.Time, planned map[tools.DataType][]pricin return near } -func GetPlannerLongestTime(end *time.Time, planned map[tools.DataType][]pricing.PricedItemITF, request *tools.APIRequest) float64 { +func GetPlannerLongestTime(end *time.Time, planned map[tools.DataType]map[string]pricing.PricedItemITF, request *tools.APIRequest) float64 { if end == nil { return -1 } diff --git a/models/workflow_execution/workflow_execution.go b/models/workflow_execution/workflow_execution.go index eb5e944..fdc21ea 100644 --- a/models/workflow_execution/workflow_execution.go +++ b/models/workflow_execution/workflow_execution.go @@ -21,7 +21,7 @@ import ( */ type WorkflowExecution struct { utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name) - PeerBookByResource map[string]map[string][]string `json:"peer_book_by_resource,omitempty" bson:"peer_book_by_resource,omitempty"` // BookByResource is a map of the resource id and the list of the booking id + PeerBookByGraph map[string]map[string][]string `json:"peer_book_by_graph,omitempty" bson:"peer_book_by_graph,omitempty"` // BookByResource is a map of the resource id and the list of the booking id ExecutionsID string `json:"executions_id,omitempty" bson:"executions_id,omitempty"` 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 @@ -109,23 +109,23 @@ func (d *WorkflowExecution) VerifyAuth(request *tools.APIRequest) bool { return true } -func (d *WorkflowExecution) Book(executionsID string, wfID string, priceds map[tools.DataType][]pricing.PricedItemITF) []*booking.Booking { +func (d *WorkflowExecution) Book(executionsID string, wfID string, priceds map[tools.DataType]map[string]pricing.PricedItemITF) []*booking.Booking { booking := d.bookEach(executionsID, wfID, tools.STORAGE_RESOURCE, priceds[tools.STORAGE_RESOURCE]) booking = append(booking, d.bookEach(executionsID, wfID, tools.PROCESSING_RESOURCE, priceds[tools.PROCESSING_RESOURCE])...) return booking } -func (d *WorkflowExecution) bookEach(executionsID string, wfID string, dt tools.DataType, priceds []pricing.PricedItemITF) []*booking.Booking { +func (d *WorkflowExecution) bookEach(executionsID string, wfID string, dt tools.DataType, priceds map[string]pricing.PricedItemITF) []*booking.Booking { items := []*booking.Booking{} - for _, priced := range priceds { - if d.PeerBookByResource == nil { - d.PeerBookByResource = map[string]map[string][]string{} + for itemID, priced := range priceds { + if d.PeerBookByGraph == nil { + d.PeerBookByGraph = map[string]map[string][]string{} } - if d.PeerBookByResource[priced.GetCreatorID()] == nil { - d.PeerBookByResource[priced.GetCreatorID()] = map[string][]string{} + if d.PeerBookByGraph[priced.GetCreatorID()] == nil { + d.PeerBookByGraph[priced.GetCreatorID()] = map[string][]string{} } - if d.PeerBookByResource[priced.GetCreatorID()][priced.GetID()] == nil { - d.PeerBookByResource[priced.GetCreatorID()][priced.GetID()] = []string{} + if d.PeerBookByGraph[priced.GetCreatorID()][itemID] == nil { + d.PeerBookByGraph[priced.GetCreatorID()][itemID] = []string{} } start := d.ExecDate if s := priced.GetLocationStart(); s != nil { @@ -148,8 +148,8 @@ func (d *WorkflowExecution) bookEach(executionsID string, wfID string, dt tools. ExpectedEndDate: &end, } items = append(items, bookingItem) - d.PeerBookByResource[priced.GetCreatorID()][priced.GetID()] = append( - d.PeerBookByResource[priced.GetCreatorID()][priced.GetID()], bookingItem.GetID()) + d.PeerBookByGraph[priced.GetCreatorID()][itemID] = append( + d.PeerBookByGraph[priced.GetCreatorID()][itemID], bookingItem.GetID()) } return items }