fix: refs #6164 Fix search in rows

This commit is contained in:
Guillermo Bonet 2024-01-22 09:35:24 +01:00
parent 4a1df1c1bf
commit 58028afc45
1 changed files with 55 additions and 32 deletions

27
main.js
View File

@ -204,6 +204,7 @@ async function main(){
if (dashboard) {
if (dashboard.panels)
for (const panel of dashboard.panels) {
// Panels
if (panel.targets)
for (const target of panel.targets) {
isFound = regexRawSQL.test(target.rawSql);
@ -219,6 +220,25 @@ async function main(){
isFoundSomething=true;
}
}
// Rows
if (panel.panels)
for (const subpanel of panel.panels) {
if (subpanel.targets)
for (const target of subpanel.targets) {
isFound = regexRawSQL.test(target.rawSql);
if (isFound) {
if (subpanel.title)
if (subpanel.title==' ')
titlePanels.push(`(null)`.italic);
else
titlePanels.push(subpanel.title);
else
titlePanels.push(`(undefined)`.italic);
numberOfPanels++;
isFoundSomething=true;
}
}
}
}
if (dashboard.templating)
@ -283,7 +303,9 @@ async function main(){
let allAlerts = await response.json();
isFound = isFoundSomething = false;
if (allAlerts.title === 'Access denied')
console.log(`${allAlerts.title}\n`.red);
else {
for (const alert of allAlerts)
for (const data of alert.data)
if (data?.model?.rawSql) {
@ -306,9 +328,10 @@ async function main(){
if (!isFoundSomething)
console.log(`No results found\n`.gray);
}
};
console.log(colors.green.bold(`─────── Have been found ${numberOfObjects} similarities in ${totalObjects} objects ───────\n`));
console.log(colors.green.bold(`─────── Have been found ${numberOfObjects} similarities in ${totalObjects} objects ───────\n`));
if (!response) {
console.log(`${error}The server don't exists`);