export TRELLO_TOKEN='<your trello token>' # found in web cookie
export TRELLO_DONE_ID='<the trello internal id of the "Done" list>'
curl -H "Cookie: token=$TRELLO_TOKEN;" -sL trello.com/b/2NFnHkvl.json \
| ./plot.sh 2018-06-01 2018-11-01 true | ./burndown.r "$(date --iso -d '+2 year')" && xdg-open burndown.svg
Last active
October 19, 2018 14:03
-
-
Save docteurklein/0dd2fe5edb625a308c0258994ec26d5e to your computer and use it in GitHub Desktop.
generate burndown charts with trello, R and jq
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
#!/usr/bin/env Rscript | |
args = commandArgs(trailingOnly=TRUE) | |
library('plan') | |
burndown <- read.burndown(file('stdin', 'r')) | |
svg(file='burndown.svg', width = 20, height = 10) | |
plot(burndown, t.stop=args[1]) | |
dev.off() |
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
#!/usr/bin/env sh | |
set -euo pipefail | |
json=$(cat -) | |
with_detail=${3:-''} | |
start=$1 | |
deadline=$2 | |
now=$(date --iso) | |
total_cards=$(jq -r '.cards | map(select(.closed == false))|length' <<< $json) | |
done_cards=$(jq --arg TRELLO_DONE_ID $TRELLO_DONE_ID -r '.cards | map(select(.closed == false and .idList == $TRELLO_DONE_ID))|length' <<< $json) | |
left_cards=$(($total_cards - $done_cards)) | |
progress=$(bc -l <<< "scale=2; $done_cards / $total_cards * 100") | |
#total_days=$(bc -l <<< "$(date -d $deadline +%s) - $(date -d $start +%s) / (24*3600)") | |
#current_days=$(bc -l <<< "$(date -d $now +%s) - $(date -d $start +%s) / (24*3600)") | |
#days_left=$(bc -l <<< "$(date -d $deadline +%s) - $(date -d $now +%s) / (24*3600)") | |
avg_card_duration=$(bc -l <<< "scale=2; $done_cards / $progress") | |
estimated_days_left=$(printf %2.f $(bc -l <<< "scale=2; $avg_card_duration * $left_cards")) | |
echo "Start, $start" | |
echo "Deadline, $deadline" | |
echo "Key, Description, Effort" | |
if [ $with_detail ]; then | |
echo $json | jq -r '.cards | map(select(.closed == false)) | to_entries | .[] | "\(.key + 1), \(.value.url|sub(".*/\\d+-"; "")), 1"' | |
echo "Key, Done, Time" | |
echo $json \ | |
| jq --arg TRELLO_DONE_ID $TRELLO_DONE_ID -r '.cards | map(select(.closed == false and .idList == $TRELLO_DONE_ID)) | to_entries | .[] |"\(.key + 1), 100, \(.value.dateLastActivity | sub("\\.[0-9]+Z$"; "Z"))"' | |
else | |
echo "1, project, $total_cards" | |
echo "Key, Done, Time" | |
unit_percent=$(bc -l <<< "scale=2; 100 / $total_cards") | |
echo $json \ | |
| jq --arg unit_percent $unit_percent --arg TRELLO_DONE_ID $TRELLO_DONE_ID -r '.cards | map(select(.closed == false and .idList == $TRELLO_DONE_ID)) | to_entries | .[] |"1, \((.key + 1) * ($unit_percent | tonumber)), \(.value.dateLastActivity | sub("\\.[0-9]+Z$"; "Z"))"' | |
fi | |
echo "total cards: $total_cards" >> /dev/stderr | |
echo "done cards: $done_cards" >> /dev/stderr | |
echo "progress: ${progress}%" >> /dev/stderr | |
echo "avg card duration: $avg_card_duration days" >> /dev/stderr | |
echo "estimated end in: $estimated_days_left days ($(date --iso -d "+${estimated_days_left} days"))" >> /dev/stderr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment