Skip to content

Instantly share code, notes, and snippets.

@paul-bjorkstrand
Last active February 19, 2021 21:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paul-bjorkstrand/dd9fa0fcb3e9c3228bd5a9e0ad6c21ac to your computer and use it in GitHub Desktop.
Save paul-bjorkstrand/dd9fa0fcb3e9c3228bd5a9e0ad6c21ac to your computer and use it in GitHub Desktop.
(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