Skip to content

Instantly share code, notes, and snippets.

@wdchris
Last active May 18, 2020 17:29
Show Gist options
  • Save wdchris/7a8a62679e8efda5def4d9adb9dbe6a3 to your computer and use it in GitHub Desktop.
Save wdchris/7a8a62679e8efda5def4d9adb9dbe6a3 to your computer and use it in GitHub Desktop.
A function to filter Trello lists based on a label
const filterCards = (boards, filter) =>
boards.reduce((result, board) => {
const cardsResult = board.lists.reduce((cards, list) => {
if (
board.closed === false &&
list.closed === false &&
(filter.length === 0 ||
list.name.toLowerCase() === filter.toLowerCase())
) {
return cards.concat(list.cards.filter(card => card.closed === false));
}
return cards;
}, []);
if (cardsResult.length > 0) {
result.push({ board: board, cards: cardsResult });
}
return result;
}, []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment