If you use Team Calendars to track your team's out of the office, vacations, sick leaves events.
Here is an example how to calculate summary per employee and present it on your Confluence.
Here I use CSV Macro from Bob Swift Table Plugin for Confluence . The idea is the following:
To do this conversion I use another host than Confluence host. This host is running on FreeBSD. So the script below works pretty well on FreeBSD, using set of built-in shell utilities so you don't need to install anything else:
#!/bin/sh sed -e 's/^M//' $1 |egrep "^BEGIN:VEVENT|^DTSTART;|^DTEND;|^SUMMARY|^END:VEVENT'| sed -e 's/^SUMMARY:\(.*\):\(.*\)/SUMMARY:\1/' |cut -d':' -f1-2 | sed -e 's/^\(DTSTART\);\(.*\):\(.*\)/\1:\3/' | sed -e 's/^\(DTEND\);\(.*\):\(.*\)/\1:\3/' | paste -d '|' - - - - - | grep ":`date "+%Y"`" | sed 's/BEGIN:VEVENT|DTSTART://' | sed 's/DTEND://' | sed 's/SUMMARY://' | sed 's/|END:VEVENT//' | sed -e 's/^\([[:digit:]]*\)T\([[:digit:]]*\)|\([[:digit:]]*\)T\([[:digit:]]*\)|\([[:alpha:]]*\)/\1\2|\3\4|\5/'|sed -e 's/^\([[:digit:]]\{8\}\)|\([[:digit:]]\{8\}\)|\(.*\)/\1000000|\2000000|\3/'|awk -F'|' 'BEGIN { OFS = "|" } { time1="date -j -f \"%Y%m%d%H%M%S\" "$1" \+\"%s\""; time2="date -j -f \"%Y%m%d%H%M%S\" "$2" \+\"%s\""; time1 | getline epoc1;close(time1); time2 | getline epoc2; close(time2); $2=epoc2-epoc1; print $3,$2}'|awk -F'|' '{array[$1]+=$2} END { for (i in array) {print i"|" array[i]}}'| sort -k 2 -n -r -t'|' | awk -F'|' '{S=$2; printf $1","; printf "%d,%d,%d\n",S/86400,S%(86400)/3600,S%3600/60}'
Updated script to be compatible with Team Calendars 4.0.1 .
#!/bin/sh sed -e 's/^M//' $1 |egrep '^BEGIN:VEVENT|^DTSTART;|^DTEND;|^SUMMARY|^END:VEVENT'| sed -e 's/^SUMMARY:\(.*\):\(.*\)/SUMMARY:\1/' |cut -d':' -f1-2 | sed -e 's/^\(DTSTART\);\(.*\):\(.*\)/\1:\3/' | sed -e 's/^\(DTEND\);\(.*\):\(.*\)/\1:\3/' | paste -d '|' - - - - - | awk -F'|' 'BEGIN { OFS="|"; } { if ($2 ~ /SUMMARY:.*/) {print $1,$4,$3,$2,$5} else {print} }' | awk -F'|' 'BEGIN { OFS="|"; } { if ($2 ~ /DTEND:.*/) {print $1,$3,$2,$4,$5} else {print} }'| awk '!x[$0]++' | grep ":`date "+%Y"`" | sed 's/BEGIN:VEVENT|DTSTART://' | sed 's/DTEND://' | sed 's/SUMMARY://' | sed 's/|END:VEVENT//' | sed -e 's/^\([[:digit:]]*\)T\([[:digit:]]*\)|\([[:digit:]]*\)T\([[:digit:]]*\)|\([[:alpha:]]*\)/\1\2|\3\4|\5/'|sed -e 's/^\([[:digit:]]\{8\}\)|\([[:digit:]]\{8\}\)|\(.*\)/\1000000|\2000000|\3/'|awk -F'|' 'BEGIN { OFS = "|" } { time1="date -j -f \"%Y%m%d%H%M%S\" "$1" \+\"%s\""; time2="date -j -f \"%Y%m%d%H%M%S\" "$2" \+\"%s\""; time1 | getline epoc1;close(time1); time2 | getline epoc2; close(time2); $2=epoc2-epoc1; print $3,$2}'|awk -F'|' '{array[$1]+=$2} END { for (i in array) {print i"|" array[i]}}'| sort -k 2 -n -r -t'|' | awk -F'|' '{S=$2; printf $1","; printf "%d,%d,%d\n",S/86400,S%(86400)/3600,S%3600/60}'
to enter "^M" in this script, type ctrl-v ctrl-m
My gosh! Crazy, but amazing work, Igor! WOW. Can I send you a Team Calendars t-shirt? :-)
Email me with your address (and size) details - sherif at atlassian dot com.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is pretty awesome Igor! Thanks for sharing!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.