Last active
February 19, 2021 21:26
-
-
Save paul-bjorkstrand/dd9fa0fcb3e9c3228bd5a9e0ad6c21ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
let response = await fetch('/system/console/status-pattern-detector.json'); | |
let text = await response.text(); | |
let json = text.replaceAll(/\n/g, ',') | |
.slice(0, -1); | |
let items = JSON.parse(`[${json}]`); | |
function getComponentName(item) { | |
//get the component name from the item | |
return ""; | |
} | |
let processedItems = items.filter((item) => item.suspicion) | |
.sort((a,b) => { | |
return a.pattern.type.localeCompare(b.pattern.code) * 100 | |
+ a.item.referring.localeCompare(b.item.referring) * 10 | |
+ a.item.referencedBy.localeCompare(b.item.referencedBy); | |
}) | |
// This is the CSV headers prepended to the CSV data | |
let header = "TYPE,ID,REFERENCE_BY,REFERRING,MESSAGE,INFO_LINK,COMPONENT_NAME"; | |
let values = processedItems | |
.map((item) => | |
`"${item.pattern.type}","${item.item.referencedBy}","${item.item.referring}","${item.item.message}","${item.pattern.moreInfo}","${getComponentName(item)}"` | |
) | |
.join('\n') | |
console.log(`${header}\n${values}`); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment