Skip to content

Commit

Permalink
fix(api) bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
helderbetiol committed Sep 12, 2024
1 parent 3bdc2a0 commit b752f7e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions API/models/impact.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package models

import (
"fmt"
u "p3/utils"
"reflect"
"strings"
Expand All @@ -17,6 +16,10 @@ type ImpactFilters struct {
}

func GetImpact(id string, userRoles map[string]Role, filters ImpactFilters) (map[string]any, *u.Error) {
directChildren := map[string]any{}
indirectChildren := map[string]any{}
clusterRelations := map[string][]string{} // map of clusterId and list of objIds linked to that cluster

// Get target object for impact analysis
target, err := GetObjectById(id, u.HIERARCHYOBJS_ENT, u.RequestFilters{}, userRoles)
if err != nil {
Expand All @@ -28,12 +31,13 @@ func GetImpact(id string, userRoles map[string]Role, filters ImpactFilters) (map
if err != nil {
return nil, err
}
fmt.Println(filters)

// Find relations
directChildren := map[string]any{}
indirectChildren := map[string]any{}
clusterRelations := map[string][]string{}
// Cluster associated to this target
if targetAttrs, ok := target["attributes"].(map[string]any); ok {
setClusterRelation(id, targetAttrs, clusterRelations)
}
// Direct/indirect children and associated clusters
targetLevel := strings.Count(id, ".")
for childId, childData := range allChildren {
childAttrs := childData.(map[string]any)["attributes"].(map[string]any)
Expand All @@ -44,6 +48,7 @@ func GetImpact(id string, userRoles map[string]Role, filters ImpactFilters) (map
setClusterRelation(childId, childAttrs, clusterRelations)
continue
}
// indirect child
setIndirectChildren(filters, childData.(map[string]any), childAttrs, indirectChildren, clusterRelations)
}

Expand Down

0 comments on commit b752f7e

Please sign in to comment.