Skip to content

Instantly share code, notes, and snippets.

@guypursey
Last active November 30, 2017 16:39
Show Gist options
  • Save guypursey/9d1258514fd844fefe86e17986f3eaed to your computer and use it in GitHub Desktop.
Save guypursey/9d1258514fd844fefe86e17986f3eaed to your computer and use it in GitHub Desktop.
Way of extracting data as TSV from Trello
members = JSON.parse(document.getElementsByTagName("pre")[0].innerHTML).members
.reduce((p, c) => { p[c.id] = c.fullName; return p }, {})
lists = JSON.parse(document.getElementsByTagName("pre")[0].innerHTML).lists
//.filter(x => !x.closed)
.reduce((p, c) => { p[c.id] = c.name; return p }, {})
labels = JSON.parse(document.getElementsByTagName("pre")[0].innerHTML).labels
.reduce((p, c) => { p[c.id] = c.name; return p }, {})
checklists = JSON.parse(document.getElementsByTagName("pre")[0].innerHTML).checklists
.reduce((p, c) => { p[c.idCard] = (p[c.idCard] || 0) + c.checkItems.filter(x => x.state === "incomplete").length; return p }, {})
pluginKeys = JSON.parse(JSON.parse(document.getElementsByTagName("pre")[0].innerHTML).pluginData[0].value).fields
.reduce((p, c) => { p[c.id] = c.n; return p }, {})
pluginData = JSON.parse(JSON.parse(document.getElementsByTagName("pre")[0].innerHTML).pluginData[0].value).fields
.reduce((p, c) => { p[c.n] = c; return p }, {})
pluginData["Size"].values = pluginData["Size"].o
.reduce((p, c) => { p[c.id] = c.value; return p }, {})
pluginData["Size"]
JSON.parse(document.getElementsByTagName("pre")[0].innerHTML).cards
.filter(x => !x.closed)
.map(c => ({
id: c.idShort,
name: c.name,
url:c.shortUrl,
cardlabels: c.idLabels.map(x => labels[x]).join(", "),
cardmembers: c.idMembers.map(x => members[x]).join(", "),
cardsize: pluginData["Size"].values[JSON.parse((((c.pluginData || [])[0] || { "value": "{\"fields\": \"\"}"})).value).fields[pluginData["Size"].id] || ""] || "",
cardhold: JSON.parse((((c.pluginData || [])[0] || { "value": "{\"fields\": \"\"}"})).value).fields[pluginData["ON HOLD"].id] || "",
list: lists[c.idList],
actions: checklists[c.id] || 0
}))
.filter(x => (x.list === "Scoping" || x.list === "Ready" || x.list === "Doing" || x.list === "Entitlements"))
.reduce((p, c) => {
let row = `${p}${c.id}\t${c.name}\t${c.cardlabels}\t${c.cardmembers}\t${c.list}\t${c.cardsize}\t${c.cardhold}\t${c.actions}\t${c.url}\n`
return row
}, "\nID\tName\tPriority\tMembers\tStatus\tSize\tOn hold?\tOutstanding actions\tURL\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment