From fe50f12c45c822593be948983fced7503240bce2 Mon Sep 17 00:00:00 2001 From: dehann Date: Mon, 27 Mar 2023 15:18:10 -0700 Subject: [PATCH 1/2] legacy fast listFactors --- src/navability/graphql/Factor.jl | 17 +++++++++++ src/navability/services/Factor.jl | 48 +++++++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/src/navability/graphql/Factor.jl b/src/navability/graphql/Factor.jl index 7e1d58f..371273b 100644 --- a/src/navability/graphql/Factor.jl +++ b/src/navability/graphql/Factor.jl @@ -15,6 +15,23 @@ fragment factor_full_fields on Factor { } """ +GQL_LISTFACTORS = """ +query sdk_list_factors ( + \$userId: ID!, + \$robotId: ID!, + \$sessionId: ID!) { + users(where:{id: \$userId}) { + robots(where:{id: \$robotId}) { + sessions(where:{id: \$sessionId}) { + factors { + label + } + } + } + } +} +""" + GQL_GETFACTOR = """ query sdk_get_factor( \$userId: ID!, diff --git a/src/navability/services/Factor.jl b/src/navability/services/Factor.jl index 917fe83..7da8753 100644 --- a/src/navability/services/Factor.jl +++ b/src/navability/services/Factor.jl @@ -95,17 +95,55 @@ end getFactors( navAbilityClient::NavAbilityClient, client::Client; detail::QueryDetail = SKELETON) = @async getFactorsEvent(navAbilityClient, client; detail ) + """ $(SIGNATURES) -Get a list of the Factors as labels in the graph. +Get a list of all factors labels in the graph. """ -function listFactors(navAbilityClient::NavAbilityClient, client::Client) - @async begin - factors = getFactors(navAbilityClient,client) |> fetch - map(v -> v["label"], factors) +function listFactorsEvent( + client::NavAbilityClient, + context::Client +) + response = client.query(QueryOptions( + "sdk_list_factors", + GQL_LISTFACTORS, + Dict( + "userId" => context.userId, + "robotId" => context.robotId, + "sessionId" => context.sessionId, + ) + )) |> fetch + payload = JSON.parse(response.Data) + try + # FIXME, this list can be empty, using try catch as lazy check + (s->s["label"]).(payload["data"]["users"][1]["robots"][1]["sessions"][1]["factors"]) + catch err + if err isa BoundsError + String[] + else + throw(err) + end end end +""" + $(SIGNATURES) +Get a list of Variable labels in the graph. + +Returns: A Task with response `::Vector{String}`. +""" +function listFactors(client::NavAbilityClient, context::Client) + @async listFactorsEvent(client, context) +end + + +# function listFactors(navAbilityClient::NavAbilityClient, client::Client) +# @async begin +# factors = getFactors(navAbilityClient,client) |> fetch +# map(v -> v["label"], factors) +# end +# end + function lsf(navAbilityClient::NavAbilityClient, client::Client) return listFactors(navAbilityClient,client) end From c5910a13eb1bda12224de5fe9babe4d5d488111f Mon Sep 17 00:00:00 2001 From: dehann Date: Mon, 27 Mar 2023 15:18:37 -0700 Subject: [PATCH 2/2] bump v0.5.2 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 4186056..286da70 100644 --- a/Project.toml +++ b/Project.toml @@ -3,7 +3,7 @@ uuid = "f3e6a059-199c-4ada-8143-fcefb97e6165" keywords = ["navability", "navigation", "slam", "sdk", "robotics", "robots"] desc = "NavAbility SDK: Access NavAbility Cloud factor graph features. Note that this SDK and the related API are still in development. Please let us know if you have any issues at info@navability.io." authors = ["NavAbility "] -version = "0.5.1" +version = "0.5.2" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"