From 787c01b4be1c3e69005f87d559087cf4b645f09e Mon Sep 17 00:00:00 2001 From: mr Date: Thu, 30 Jan 2025 09:45:13 +0100 Subject: [PATCH] adding inputs output struct based on argo naming for now --- models/workflow/workflow.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/models/workflow/workflow.go b/models/workflow/workflow.go index 6a20fa0..2fe6573 100644 --- a/models/workflow/workflow.go +++ b/models/workflow/workflow.go @@ -52,8 +52,13 @@ func (w *Workflow) GetPricedItem(f func(item graph.GraphItem) bool, request *too return list_datas } -func (w *Workflow) GetByRelatedProcessing(processingID string, g func(item graph.GraphItem) bool) []resources.ResourceInterface { - storages := []resources.ResourceInterface{} +type Related struct { + Nodes []resources.ResourceInterface + Links []graph.GraphLink +} + +func (w *Workflow) GetByRelatedProcessing(processingID string, g func(item graph.GraphItem) bool) map[string]Related { + related := map[string]Related{} for _, link := range w.Graph.Links { nodeID := link.Destination.ID var node resources.ResourceInterface @@ -67,10 +72,16 @@ func (w *Workflow) GetByRelatedProcessing(processingID string, g func(item graph _, node = item.GetResource() // we are looking for the storage as destination } if processingID == nodeID && node != nil { // if the storage is linked to the processing - storages = append(storages, node) + if _, ok := related[processingID]; !ok { + related[processingID] = Related{} + } + rel := related[processingID] + rel.Nodes = append(rel.Nodes, node) + rel.Links = append(rel.Links, link) + related[processingID] = rel } } - return storages + return related } func (ao *Workflow) VerifyAuth(request *tools.APIRequest) bool {