Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Q
query-service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GraphPolaris
Microservices
query-service
Commits
a6349f61
Commit
a6349f61
authored
3 years ago
by
Bouma,C.J. (Chris)
Browse files
Options
Downloads
Patches
Plain Diff
Fixed query bug
Wrong things being passed, should work now woo!
parent
38aa4f64
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
integration-testing/config.json
+5
-4
5 additions, 4 deletions
integration-testing/config.json
internal/usecases/request/request.go
+22
-15
22 additions, 15 deletions
internal/usecases/request/request.go
with
27 additions
and
19 deletions
integration-testing/config.json
+
5
−
4
View file @
a6349f61
...
...
@@ -6,21 +6,22 @@
"exchange"
:
"requests-exchange"
,
"exchangeType"
:
"direct"
,
"messages"
:
[
{
"routingKey"
:
"aql-query-request"
,
"headers"
:
{
"sessionID"
:
"test-session"
,
"clientID"
:
"c2
4l4v
d2ngurnrncj
di0
"
"clientID"
:
"c2
8ha5
d2ngurnrncj
gkg
"
},
"data"
:
"
This is not a valid query
"
"data"
:
"
{
\"
DatabaseName
\"
:
\"
test
\"
,
\"
Return
\"
:{
\"
Entities
\"
:[0,1],
\"
Relations
\"
:[0]},
\"
Entities
\"
:[{
\"
Type
\"
:
\"
airports
\"
,
\"
Constraints
\"
:[{
\"
Attribute
\"
:
\"
city
\"
,
\"
Value
\"
:
\"
New York
\"
,
\"
DataType
\"
:
\"
text
\"
,
\"
MatchType
\"
:
\"
exact
\"
}]},{
\"
Type
\"
:
\"
airports
\"
,
\"
Constraints
\"
:[{
\"
Attribute
\"
:
\"
city
\"
,
\"
Value
\"
:
\"
San Francisco
\"
,
\"
DataType
\"
:
\"
text
\"
,
\"
MatchType
\"
:
\"
exact
\"
},{
\"
Attribute
\"
:
\"
vip
\"
,
\"
Value
\"
:
\"
true
\"
,
\"
DataType
\"
:
\"
bool
\"
,
\"
MatchType
\"
:
\"
exact
\"
}]}],
\"
Relations
\"
:[{
\"
Type
\"
:
\"
flights
\"
,
\"
Depth
\"
:{
\"
min
\"
:1,
\"
max
\"
:1},
\"
EntityFrom
\"
:0,
\"
EntityTo
\"
:1,
\"
Constraints
\"
:[{
\"
Attribute
\"
:
\"
Month
\"
,
\"
Value
\"
:
\"
1
\"
,
\"
DataType
\"
:
\"
number
\"
,
\"
MatchType
\"
:
\"
exact
\"
},{
\"
Attribute
\"
:
\"
Day
\"
,
\"
Value
\"
:
\"
15
\"
,
\"
DataType
\"
:
\"
number
\"
,
\"
MatchType
\"
:
\"
exact
\"
}]}],
\"
limit
\"
: 1000}
"
},
{
"routingKey"
:
"aql-query-request"
,
"headers"
:
{
"sessionID"
:
"test-session"
,
"clientID"
:
"c2
4l4v
d2ngurnrncj
di0
"
"clientID"
:
"c2
8ha5
d2ngurnrncj
gkg
"
},
"data"
:
"
{
\"
DatabaseName
\"
:
\"
test
\"
,
\"
Return
\"
:{
\"
Entities
\"
:[0,1],
\"
Relations
\"
:[0]},
\"
Entities
\"
:[{
\"
Type
\"
:
\"
airports
\"
,
\"
Constraints
\"
:[{
\"
Attribute
\"
:
\"
city
\"
,
\"
Value
\"
:
\"
New York
\"
,
\"
DataType
\"
:
\"
text
\"
,
\"
MatchType
\"
:
\"
exact
\"
}]},{
\"
Type
\"
:
\"
airports
\"
,
\"
Constraints
\"
:[{
\"
Attribute
\"
:
\"
city
\"
,
\"
Value
\"
:
\"
San Francisco
\"
,
\"
DataType
\"
:
\"
text
\"
,
\"
MatchType
\"
:
\"
exact
\"
},{
\"
Attribute
\"
:
\"
vip
\"
,
\"
Value
\"
:
\"
true
\"
,
\"
DataType
\"
:
\"
bool
\"
,
\"
MatchType
\"
:
\"
exact
\"
}]}],
\"
Relations
\"
:[{
\"
Type
\"
:
\"
flights
\"
,
\"
Depth
\"
:{
\"
min
\"
:1,
\"
max
\"
:1},
\"
EntityFrom
\"
:0,
\"
EntityTo
\"
:1,
\"
Constraints
\"
:[{
\"
Attribute
\"
:
\"
Month
\"
,
\"
Value
\"
:
\"
1
\"
,
\"
DataType
\"
:
\"
number
\"
,
\"
MatchType
\"
:
\"
exact
\"
},{
\"
Attribute
\"
:
\"
Day
\"
,
\"
Value
\"
:
\"
15
\"
,
\"
DataType
\"
:
\"
number
\"
,
\"
MatchType
\"
:
\"
exact
\"
}]}],
\"
limit
\"
: 1000}
"
"data"
:
"
This is not a valid query
"
}
]
}
...
...
This diff is collapsed.
Click to expand it.
internal/usecases/request/request.go
+
22
−
15
View file @
a6349f61
...
...
@@ -75,32 +75,39 @@ func (s *Service) SendAQLQuery(query string, username string, password string, h
break
}
else
if
err
!=
nil
{
// handle other errors
fmt
.
Println
(
err
)
return
nil
,
err
}
// If the result is only numerical, break out of the loop
num
,
isNum
=
doc
.
(
float64
)
if
isNum
{
// Switch on the type of return, to filter out the case of a single number
switch
doc
.
(
type
)
{
case
float64
:
num
=
doc
.
(
float64
)
isNum
=
true
break
case
map
[
string
]
interface
{}
:
pdoc
:=
doc
.
(
map
[
string
]
interface
{})
parseResult
(
pdoc
,
&
listContainer
)
break
default
:
fmt
.
Println
(
"Incompatible result type"
)
break
}
parseResult
(
doc
,
&
listContainer
)
}
if
!
isNum
{
// Return nodes and edges
queryResult
[
"nodes"
]
=
listContainer
.
NodeList
queryResult
[
"edges"
]
=
listContainer
.
EdgeList
//writeJSON(queryResult)
//file, err := json.MarshalIndent(queryResult, "", " ")
jsonQ
,
err
:=
json
.
Marshal
(
queryResult
)
return
&
jsonQ
,
err
}
else
{
// Return just a number
numQ
,
err
:=
json
.
Marshal
(
num
)
return
&
numQ
,
err
}
numQ
,
err
:=
json
.
Marshal
(
num
)
return
&
numQ
,
err
}
/* parseResult takes the result of the query and translates this to two lists: a nodelist and an edgelist, stored in a listcontainer
...
...
@@ -110,11 +117,11 @@ listContainer is a struct containing the nodelist and edgelist that will be retu
Return: Nothing because the result is stored in the listContainer
*/
func
parseResult
(
incomingDoc
interface
{},
listContainer
*
entity
.
ListContainer
)
{
func
parseResult
(
doc
map
[
string
]
interface
{},
listContainer
*
entity
.
ListContainer
)
{
doc
:=
incomingDoc
.
(
map
[
string
][]
interface
{})
vertices
:=
doc
[
"vertices"
]
edges
:=
doc
[
"edges"
]
//
doc
, ok
:= incomingDoc.(map[string][]interface{})
vertices
:=
doc
[
"vertices"
]
.
([]
interface
{})
edges
:=
doc
[
"edges"
]
.
([]
interface
{})
for
_
,
vertex
:=
range
vertices
{
vertexDoc
:=
vertex
.
(
map
[
string
]
interface
{})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment