Created
July 26, 2019 18:02
-
-
Save CermakM/1a9df3f4dafc08bda49a562e747d2858 to your computer and use it in GitHub Desktop.
Simple Trello story point counter
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
/** | |
* This is a Trello plugin for counting story points from card names. | |
* | |
* Usage: | |
* 1) Have SP set in card title as such "(<SP>) <title>" | |
*/ | |
function getSPFromCardName(card) { | |
const p = /\((\d+)\)/ | |
const m = card.match(p) | |
if (m) | |
return Number(m[1]) | |
return 0 | |
} | |
function setColumnName(id, name) { | |
Trello.put(`/lists/${id}`, { | |
name: name | |
}) | |
} | |
_COLUMN_REGEX = [/^Completed.*/, /^Next.*/, /^In Progress.*/]; | |
(function() { | |
Trello.board.get().then((board)=>{ | |
const lists = board.lists | |
lists.forEach(async(list)=>{ | |
if (list.closed || !_COLUMN_REGEX.some(p=>p.test(list.name))) | |
return | |
const cards = await Trello.lists.get(`${list.id}/cards`) | |
const storyPoints = cards.map(card=>Number(getSPFromCardName(card.name))) | |
const total = storyPoints.reduce((a,b)=>a + b, 0) | |
const columnName = list.name.replace(/ \(Total SP: \d+\)/, '') | |
console.debug("Updating list: ", columnName, list) | |
setColumnName(list.id, `${columnName} (Total SP: ${total})`) | |
}) | |
}) | |
}()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment