Last active
June 28, 2019 00:04
-
-
Save markdon/6d4037914306e8a9c40e6a99eb464c0d to your computer and use it in GitHub Desktop.
[Boards Comment Finder] This script will count the comments on each card individually and open the card with the most comments
This file contains hidden or 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
(()=>{ | |
const boardNode = Boards.current.boardNode; | |
const results = { | |
[boardNode.id]:{ | |
id:boardNode.id, replies:0, hashURL:boardNode.getHashURL() | |
} | |
}; | |
const nodes = Boards.current.boardNode.getAllDescendants(); | |
// initialize results | |
nodes.forEach( node => results[node.id] = {id: node.id, replies:0, url:node.getAbsoluteURL()}); | |
// count the replies | |
nodes.forEach( node => node.attributes.commonType === "reply" && node.attributes.parentId && results[node.attributes.parentId].replies++); | |
// return array sorted by reply count | |
const sortedResults = Object.values(results).sort((a, b) => b.replies - a.replies); | |
window.location = sortedResults[0].url; | |
return sortedResults; | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment