From 4a6edade74fcc2dd5bb4a314fadd7b570f889826 Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Tue, 13 Jun 2023 14:23:33 -0600 Subject: [PATCH] Fixed GQLVexQueryArenas --- gql_vex.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/gql_vex.go b/gql_vex.go index 2b7838a..1f63cb7 100644 --- a/gql_vex.go +++ b/gql_vex.go @@ -26,11 +26,26 @@ func GQLVexQueries() map[string]*graphql.Field { func FindResources(event Event, resource_type reflect.Type) []Resource { resources := event.RequiredResources() + found := []Resource{} + for _, resource := range(resources) { + if reflect.TypeOf(resource) == resource_type { + found = append(found, resource) + } + } + for _, child := range(event.Children()) { - resources = append(resources, FindResources(child, resource_type)...) + found = append(found, FindResources(child, resource_type)...) } - return resources + m := map[string]Resource{} + for _, resource := range(found) { + m[resource.ID()] = resource + } + ret := []Resource{} + for _, resource := range(m) { + ret = append(ret, resource) + } + return ret } var gql_vex_query_arenas *graphql.Field = nil @@ -48,7 +63,7 @@ func GQLVexQueryArenas() *graphql.Field { if is_event == false { return nil, fmt.Errorf("Can't enumerate arenas when server is attached to resource") } - return FindResources(owner, reflect.TypeOf((*Arena)(nil))), nil + return FindResources(owner, reflect.TypeOf((*VirtualArena)(nil))), nil }, } }