Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Q
query-conversion
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
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
query-conversion
Commits
a97db900
Commit
a97db900
authored
3 years ago
by
Kieran van Gaalen
Browse files
Options
Downloads
Patches
Plain Diff
filter chaining
parent
7c6bee0f
No related branches found
No related tags found
1 merge request
!1
Big merge
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
aql/convertQuery.go
+15
-7
15 additions, 7 deletions
aql/convertQuery.go
aql/hierarchy.go
+1
-2
1 addition, 2 deletions
aql/hierarchy.go
main/main.go
+1
-1
1 addition, 1 deletion
main/main.go
test3.json
+67
-0
67 additions, 0 deletions
test3.json
with
84 additions
and
10 deletions
aql/convertQuery.go
+
15
−
7
View file @
a97db900
...
...
@@ -115,11 +115,12 @@ func relationToQuery(element entity.QueryRelationStruct, JSONQuery *entity.Incom
if
len
(
filters
)
>
0
{
for
i
:=
range
filters
{
filter
:=
filters
[
i
]
fmt
.
Println
(
filter
.
FromID
)
fmt
.
Println
(
element
.
FromID
)
fmt
.
Println
(
filter
.
FromType
)
fmt
.
Println
(
element
.
FromType
)
if
filter
.
FromType
==
element
.
FromType
&&
filter
.
FromID
==
element
.
FromID
{
filter2
:=
filter
for
filter2
.
FromType
==
"filter"
{
filters2
:=
tryGetFilterTo
(
"filter"
,
filter
.
ID
,
JSONQuery
)
filter2
=
filters2
[
0
]
}
if
filter2
.
FromType
==
element
.
FromType
&&
filter2
.
FromID
==
element
.
FromID
{
ret
+=
fmt
.
Sprintf
(
"
\t
FOR y in f%v
\n
"
,
filter
.
ID
)
ydefined
=
true
}
else
{
...
...
@@ -154,7 +155,14 @@ func functionToQuery(element entity.QueryGroupByStruct, JSONQuery *entity.Incomi
func
filterToQuery
(
element
entity
.
QueryFilterStruct
,
JSONQuery
*
entity
.
IncomingQueryJSON
)
string
{
thisname
:=
fmt
.
Sprintf
(
"f%v"
,
element
.
ID
)
ret
:=
createLetFor
(
thisname
,
fmt
.
Sprintf
(
"%v%v"
,
typeToPrefix
(
element
.
FromType
),
element
.
FromID
))
var
filteredpill
string
filters
:=
tryGetFilterTo
(
"filter"
,
element
.
ID
,
JSONQuery
)
if
len
(
filters
)
>
0
{
filteredpill
=
fmt
.
Sprintf
(
"f%v"
,
filters
[
0
]
.
ID
)
}
else
{
filteredpill
=
fmt
.
Sprintf
(
"%v%v"
,
typeToPrefix
(
element
.
FromType
),
element
.
FromID
)
}
ret
:=
createLetFor
(
thisname
,
filteredpill
)
if
element
.
FromType
==
"groupBy"
{
ret
+=
fmt
.
Sprintf
(
"
\t
FILTER x.modifier %v %v
\n
"
,
wordsToLogicalSign
((
element
.
MatchType
)),
element
.
Value
)
}
else
{
...
...
@@ -242,7 +250,7 @@ func createGroupBy(element entity.QueryGroupByStruct, JSONQuery *entity.Incoming
tuplename
:=
fmt
.
Sprintf
(
"gt%v"
,
element
.
ID
)
result
:=
createLetFor
(
thisname
,
tuplename
)
result
+=
createCollect
(
element
)
result
+=
"
\t
RETURN {
\n\t
_id: c,
\n\t
\"
modifier
\"
: variable_0
\n\t
}
\n
)
\n
"
result
+=
"
\t
RETURN {
\n\t
_id: c,
\n\t
modifier: variable_0
\n\t
}
\n
)
\n
"
return
result
}
...
...
This diff is collapsed.
Click to expand it.
aql/hierarchy.go
+
1
−
2
View file @
a97db900
...
...
@@ -394,7 +394,6 @@ func FuncToAllRel(JSONQuery *entity.IncomingQueryJSON, function pdict) {
}
func
AddFilters
(
JSONQuery
*
entity
.
IncomingQueryJSON
)
{
for
i
,
filter
:=
range
JSONQuery
.
Filters
{
if
_
,
ok
:=
filterDone
[
i
];
!
ok
{
p
:=
pdict
{
...
...
@@ -413,7 +412,7 @@ func AddFilters(JSONQuery *entity.IncomingQueryJSON) {
func
addOneFilter
(
filterPDict
pdict
,
JSONQuery
*
entity
.
IncomingQueryJSON
,
p
pdict
,
filterDone
*
map
[
int
]
bool
)
{
if
p
.
typename
==
"filter"
&&
(
*
filterDone
)[
p
.
pointer
]
{
l
:=
FindCurrentLayer
(
listoflists
,
p
)
k
:=
pdictList
{}
k
:=
pdictList
{
filterPDict
}
if
len
(
listoflists
)
>
l
+
1
&&
listoflists
[
l
+
1
][
0
]
.
typename
==
"filter"
{
listoflists
[
l
+
1
]
=
append
(
listoflists
[
l
+
1
],
filterPDict
)
}
else
{
...
...
This diff is collapsed.
Click to expand it.
main/main.go
+
1
−
1
View file @
a97db900
...
...
@@ -20,7 +20,7 @@ The main function that calls the appropriate functions
*/
func
main
()
{
queryservice
:=
aql
.
NewService
()
jsonFile
,
err
:=
os
.
Open
(
"../test
2
.json"
)
jsonFile
,
err
:=
os
.
Open
(
"../test
3
.json"
)
// if we os.Open returns an error then handle it
if
err
!=
nil
{
log
.
Println
(
err
)
...
...
This diff is collapsed.
Click to expand it.
test3.json
0 → 100644
+
67
−
0
View file @
a97db900
{
"return"
:
{
"entities"
:
[
0
,
1
],
"relations"
:
[
0
]
},
"entities"
:
[
{
"ID"
:
0
,
"name"
:
"parliament"
},
{
"ID"
:
1
,
"name"
:
"parties"
}
],
"relations"
:
[
{
"ID"
:
0
,
"name"
:
"member_of"
,
"depth"
:
{
"min"
:
1
,
"max"
:
1
},
"fromType"
:
"entity"
,
"fromID"
:
0
,
"toType"
:
"entity"
,
"toID"
:
1
}
],
"groupBys"
:
[],
"filters"
:
[
{
"ID"
:
0
,
"fromType"
:
"entity"
,
"fromID"
:
0
,
"toType"
:
"filter"
,
"toID"
:
1
,
"attribute"
:
"age"
,
"value"
:
"40"
,
"dataType"
:
"number"
,
"matchType"
:
"GT"
,
"inType"
:
""
,
"inID"
:
0
},
{
"ID"
:
1
,
"fromType"
:
"filter"
,
"fromID"
:
0
,
"toType"
:
"relation"
,
"toID"
:
0
,
"attribute"
:
"seniority"
,
"value"
:
"3000"
,
"dataType"
:
"number"
,
"matchType"
:
"GT"
,
"inType"
:
""
,
"inID"
:
0
}
],
"limit"
:
5000
,
"modifiers"
:
[],
"databaseName"
:
"Tweede Kamer Dataset"
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Heijden,T.A.J. van der (Thijs)
@t.a.j.vanderheijden
mentioned in commit
82d6956b
·
3 years ago
mentioned in commit
82d6956b
mentioned in commit 82d6956b25f2a5a9942b9ef3014309c1aefed134
Toggle commit list
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