Skip to content

Instantly share code, notes, and snippets.

@markdon
Last active June 28, 2019 00:04
Show Gist options
  • Save markdon/6d4037914306e8a9c40e6a99eb464c0d to your computer and use it in GitHub Desktop.
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
(()=>{
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