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
Compare revisions
v1.17.0 to v1.18.0
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
graphpolaris/microservices/query-service
Select target project
No results found
v1.18.0
Select Git revision
Swap
Target
graphpolaris/microservices/query-service
Select target project
graphpolaris/microservices/query-service
1 result
v1.17.0
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (1)
feat: implement multiple queries
· 6a03c1df
Dennis Collaris
authored
2 months ago
6a03c1df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/readers/insightProcessor.ts
+59
-55
59 additions, 55 deletions
src/readers/insightProcessor.ts
src/readers/queryService.ts
+25
-2
25 additions, 2 deletions
src/readers/queryService.ts
with
84 additions
and
57 deletions
src/readers/insightProcessor.ts
View file @
6a03c1df
...
@@ -84,65 +84,69 @@ export const insightProcessor = async () => {
...
@@ -84,65 +84,69 @@ export const insightProcessor = async () => {
if
(
insight
.
userId
==
null
)
return
;
if
(
insight
.
userId
==
null
)
return
;
const
ss
=
await
ums
.
getUserSaveState
(
insight
.
userId
,
insight
.
saveStateId
);
const
ss
=
await
ums
.
getUserSaveState
(
insight
.
userId
,
insight
.
saveStateId
);
const
queries
=
ss
.
queryStates
.
openQueryArray
;
const
visualizations
=
ss
.
visualizations
.
openVisualizationArray
;
const
visualizations
=
ss
.
visualizations
.
openVisualizationArray
;
const
visualQuery
=
ss
.
queries
[
0
].
graph
;
const
queryBuilderSettings
=
ss
.
queries
[
0
].
settings
;
const
convertedQuery
=
Query2BackendQuery
(
ss
.
id
,
visualQuery
,
queryBuilderSettings
,
[]);
const
query
=
query2Cypher
(
convertedQuery
);
if
(
query
==
null
)
return
;
try
{
const
result
=
await
queryService
(
ss
.
dbConnections
[
0
],
query
);
insight
.
status
=
false
;
if
(
insight
.
alarmMode
===
'
always
'
)
{
insight
.
status
=
true
;
}
else
if
(
insight
.
alarmMode
===
'
diff
'
)
{
insight
=
await
diffCheck
(
insight
,
ss
,
result
);
}
else
if
(
insight
.
alarmMode
===
'
conditional
'
&&
insight
.
conditionsCheck
&&
insight
.
conditionsCheck
.
length
>
0
)
{
insight
=
statCheck
(
insight
,
result
);
}
if
(
insight
.
userId
==
null
)
return
;
// fixes ts but never is the case
await
ums
.
updateInsight
(
insight
.
userId
,
insight
.
id
,
insight
);
if
(
insight
.
status
||
message
.
force
)
{
if
(
insight
.
status
)
log
.
debug
(
'
Insight passed the check
'
);
if
(
message
.
force
)
log
.
debug
(
'
Forced insight processing
'
);
editor
.
read
(
async
()
=>
{
const
cleanUpDom
=
setUpDom
();
let
html
=
$generateHtmlFromNodes
(
editor
);
cleanUpDom
();
html
=
await
populateTemplate
(
html
,
result
,
visualizations
);
for
(
const
queryIndex
in
queries
)
{
const
visualQuery
=
ss
.
queryStates
.
openQueryArray
[
queryIndex
].
graph
;
for
(
const
recipient
of
insight
.
recipients
)
{
const
queryBuilderSettings
=
ss
.
queryStates
.
openQueryArray
[
queryIndex
].
settings
;
if
(
mail
==
null
)
{
const
convertedQuery
=
Query2BackendQuery
(
ss
.
id
,
visualQuery
,
queryBuilderSettings
,
[]);
log
.
warn
(
'
Mail is not configured. Insight processor will be disabled
'
);
const
query
=
query2Cypher
(
convertedQuery
);
return
;
if
(
query
==
null
)
return
;
}
try
{
const
result
=
await
queryService
(
ss
.
dbConnections
[
0
],
query
);
if
(
DEBUG_EMAIL
)
{
log
.
warn
(
'
DEBUG: Would have sent mail to
'
,
recipient
);
insight
.
status
=
false
;
continue
;
if
(
insight
.
alarmMode
===
'
always
'
)
{
insight
.
status
=
true
;
}
else
if
(
insight
.
alarmMode
===
'
diff
'
)
{
insight
=
await
diffCheck
(
insight
,
ss
,
result
);
}
else
if
(
insight
.
alarmMode
===
'
conditional
'
&&
insight
.
conditionsCheck
&&
insight
.
conditionsCheck
.
length
>
0
)
{
insight
=
statCheck
(
insight
,
result
);
}
if
(
insight
.
userId
==
null
)
return
;
// fixes ts but never is the case
await
ums
.
updateInsight
(
insight
.
userId
,
insight
.
id
,
insight
);
if
(
insight
.
status
||
message
.
force
)
{
if
(
insight
.
status
)
log
.
debug
(
'
Insight passed the check
'
);
if
(
message
.
force
)
log
.
debug
(
'
Forced insight processing
'
);
editor
.
read
(
async
()
=>
{
const
cleanUpDom
=
setUpDom
();
let
html
=
$generateHtmlFromNodes
(
editor
);
cleanUpDom
();
html
=
await
populateTemplate
(
html
,
result
,
visualizations
);
for
(
const
recipient
of
insight
.
recipients
)
{
if
(
mail
==
null
)
{
log
.
warn
(
'
Mail is not configured. Insight processor will be disabled
'
);
return
;
}
if
(
DEBUG_EMAIL
)
{
log
.
warn
(
'
DEBUG: Would have sent mail to
'
,
recipient
);
continue
;
}
log
.
debug
(
'
Sending mail to
'
,
recipient
);
await
mail
.
sendMail
({
to
:
recipient
,
from
:
SMTP_USER
,
subject
:
`GraphPolaris report:
${
insight
.
name
}
`
,
html
:
html
,
});
log
.
info
(
'
Mail sent to
'
,
recipient
);
}
}
});
log
.
debug
(
'
Sending mail to
'
,
recipient
);
}
else
{
await
mail
.
sendMail
({
log
.
debug
(
'
WARN: Insight did not pass the check
'
);
to
:
recipient
,
}
from
:
SMTP_USER
,
}
catch
(
err
)
{
subject
:
`GraphPolaris report:
${
insight
.
name
}
`
,
log
.
error
(
'
Error processing insight
'
,
err
);
html
:
html
,
});
log
.
info
(
'
Mail sent to
'
,
recipient
);
}
});
}
else
{
log
.
debug
(
'
WARN: Insight did not pass the check
'
);
}
}
}
catch
(
err
)
{
log
.
error
(
'
Error processing insight
'
,
err
);
}
}
});
});
};
};
This diff is collapsed.
Click to expand it.
src/readers/queryService.ts
View file @
6a03c1df
...
@@ -105,7 +105,30 @@ export const queryServiceReader = async (frontendPublisher: RabbitMqBroker, mlPu
...
@@ -105,7 +105,30 @@ export const queryServiceReader = async (frontendPublisher: RabbitMqBroker, mlPu
return
;
return
;
}
}
const
visualQuery
=
ss
.
queries
[
0
].
graph
;
let
activeQuery
=
ss
.
queryStates
.
activeQueryId
;
if
(
message
.
queryID
)
{
if
(
ss
.
queryStates
.
openQueryArray
.
find
(
q
=>
q
.
id
===
message
.
queryID
)
==
null
)
{
log
.
error
(
'
Query not found in SaveState:
'
,
message
.
queryID
,
ss
.
queryStates
.
openQueryArray
);
publisher
.
publishErrorToFrontend
(
'
Query not found
'
);
return
;
}
activeQuery
=
message
.
queryID
;
}
if
(
activeQuery
==
null
||
activeQuery
==
-
1
)
{
log
.
error
(
'
No active query found in SaveState:
'
,
ss
);
publisher
.
publishErrorToFrontend
(
'
No active query found
'
);
return
;
}
const
activeQueryInfo
=
ss
.
queryStates
.
openQueryArray
.
find
(
q
=>
q
.
id
===
activeQuery
);
if
(
activeQueryInfo
==
null
)
{
log
.
error
(
'
Active query not found in SaveState:
'
,
ss
.
queryStates
.
activeQueryId
,
ss
.
queryStates
.
openQueryArray
);
publisher
.
publishErrorToFrontend
(
'
Active query not found
'
);
return
;
}
const
visualQuery
=
activeQueryInfo
.
graph
;
//ss.queries[0].graph;
log
.
debug
(
'
Received query request:
'
,
message
,
headers
,
visualQuery
);
log
.
debug
(
'
Received query request:
'
,
message
,
headers
,
visualQuery
);
if
(
visualQuery
.
nodes
.
length
===
0
)
{
if
(
visualQuery
.
nodes
.
length
===
0
)
{
log
.
info
(
'
Empty query received
'
);
log
.
info
(
'
Empty query received
'
);
...
@@ -121,7 +144,7 @@ export const queryServiceReader = async (frontendPublisher: RabbitMqBroker, mlPu
...
@@ -121,7 +144,7 @@ export const queryServiceReader = async (frontendPublisher: RabbitMqBroker, mlPu
return
;
return
;
}
}
const
queryBuilderSettings
=
ss
.
queries
[
0
].
settings
;
const
queryBuilderSettings
=
activeQueryInfo
.
settings
;
//
ss.queries[0].settings;
const
ml
=
message
.
ml
;
const
ml
=
message
.
ml
;
const
convertedQuery
=
Query2BackendQuery
(
ss
.
id
,
visualQuery
,
queryBuilderSettings
,
ml
);
const
convertedQuery
=
Query2BackendQuery
(
ss
.
id
,
visualQuery
,
queryBuilderSettings
,
ml
);
...
...
This diff is collapsed.
Click to expand it.