|
|
|
@ -12,8 +12,13 @@ export async function convertPanelUrlToPanelId() {
|
|
|
|
|
|
|
|
|
|
const panelUrlRegex = /^(.+)\/d\/(\w+)\/.+panelId=(\d+)/; |
|
|
|
|
const newPanelUrlRegex = /^(.+)\/dashboard\/(\w+).+panelId=(\d+)/; |
|
|
|
|
const updatedAnalyticUnits = analyticUnits.map(analyticUnit => { |
|
|
|
|
const updatedAnalyticUnits = analyticUnits |
|
|
|
|
.map(analyticUnit => { |
|
|
|
|
const parsedPanelUrl = analyticUnit.panelUrl.match(panelUrlRegex) || analyticUnit.panelUrl.match(newPanelUrlRegex); |
|
|
|
|
if(parsedPanelUrl === null) { |
|
|
|
|
console.log(`Cannot parse url: ${analyticUnit.panelUrl}`); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
const grafanaUrl = parsedPanelUrl[1]; |
|
|
|
|
const dashboardId = parsedPanelUrl[2]; |
|
|
|
|
const oldPanelId = parsedPanelUrl[3]; |
|
|
|
@ -24,7 +29,8 @@ export async function convertPanelUrlToPanelId() {
|
|
|
|
|
grafanaUrl, |
|
|
|
|
panelId |
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
.filter(analyticUnit => analyticUnit !== null); |
|
|
|
|
|
|
|
|
|
console.log(updatedAnalyticUnits); |
|
|
|
|
await updatedAnalyticUnits.forEach(analyticUnit => db.updateOne(analyticUnit._id, { |
|
|
|
|