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
4c8b1c67
Verified
Commit
4c8b1c67
authored
2 months ago
by
Dennis Collaris
Browse files
Options
Downloads
Patches
Plain Diff
fix: run all save state queries in insight processor, not only the active one
parent
8dc624bc
No related branches found
No related tags found
1 merge request
!27
feat: implement multiple queries
Pipeline
#145000
passed
2 months ago
Stage: tag-release
Stage: get-release-tag
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/readers/insightProcessor.ts
+59
-60
59 additions, 60 deletions
src/readers/insightProcessor.ts
with
59 additions
and
60 deletions
src/readers/insightProcessor.ts
+
59
−
60
View file @
4c8b1c67
...
...
@@ -84,70 +84,69 @@ export const insightProcessor = async () => {
if
(
insight
.
userId
==
null
)
return
;
const
ss
=
await
ums
.
getUserSaveState
(
insight
.
userId
,
insight
.
saveStateId
);
const
activeQuery
=
ss
.
queries
.
activeQueryId
;
if
(
activeQuery
==
null
||
activeQuery
==
-
1
)
{
log
.
error
(
'
No active query found in SaveState:
'
,
ss
);
return
;
}
const
queries
=
ss
.
queries
.
openQueryArray
;
const
visualizations
=
ss
.
visualizations
.
openVisualizationArray
;
const
visualQuery
=
ss
.
queries
.
openQueryArray
[
activeQuery
].
graph
;
const
queryBuilderSettings
=
ss
.
queries
.
openQueryArray
[
activeQuery
].
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
recipient
of
insight
.
recipients
)
{
if
(
mail
==
null
)
{
log
.
warn
(
'
Mail is not configured. Insight processor will be disabled
'
);
return
;
for
(
const
queryIndex
in
queries
)
{
const
visualQuery
=
ss
.
queries
.
openQueryArray
[
queryIndex
].
graph
;
const
queryBuilderSettings
=
ss
.
queries
.
openQueryArray
[
queryIndex
].
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
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
);
}
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
);
}
});
}
else
{
log
.
debug
(
'
WARN: Insight did not pass the check
'
);
});
}
else
{
log
.
debug
(
'
WARN: Insight did not pass the check
'
);
}
}
catch
(
err
)
{
log
.
error
(
'
Error processing insight
'
,
err
);
}
}
catch
(
err
)
{
log
.
error
(
'
Error processing insight
'
,
err
);
}
});
};
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