#!/bin/bash
cd /home/reiffert/public_html/macports/ || exit -1
DATE=$(date +%Y-%m-%d)
wget "http://trac.macports.org/query?status=assigned" -O 1
wget "http://trac.macports.org/query?status=reopened" -O 2
wget "http://trac.macports.org/query?status=new&owner=macports-tickets%40lists.macosforge.org" -O 3
wget "http://trac.macports.org/query?status=new&owner=%21macports-tickets%40lists.macosforge.org" -O 4
num1=$(grep matches 1 | cut -d '(' -f 2 | cut -d ' ' -f 1)
num2=$(grep matches 2 | cut -d '(' -f 2 | cut -d ' ' -f 1)
num3=$(grep matches 3 | cut -d '(' -f 2 | cut -d ' ' -f 1)
num4=$(grep matches 4 | cut -d '(' -f 2 | cut -d ' ' -f 1)
echo -e "$DATE\t${num1}\t${num2}\t${num3}\t${num4}" >> ticket-status-all.txt
wget "http://trac.macports.org/query?status=new&status=assigned&status=reopened&type=defect" -O 5
wget "http://trac.macports.org/query?status=new&status=assigned&status=reopened&type=enhancement" -O 6
wget "http://trac.macports.org/query?status=new&status=assigned&status=reopened&type=update" -O 7
wget "http://trac.macports.org/query?status=new&status=assigned&status=reopened&type=submission" -O 8
wget "http://trac.macports.org/query?status=new&status=assigned&status=reopened&type=request" -O 9
num1=$(grep matches 5 | cut -d '(' -f 2 | cut -d ' ' -f 1)
num2=$(grep matches 6 | cut -d '(' -f 2 | cut -d ' ' -f 1)
num3=$(grep matches 7 | cut -d '(' -f 2 | cut -d ' ' -f 1)
num4=$(grep matches 8 | cut -d '(' -f 2 | cut -d ' ' -f 1)
num5=$(grep matches 9 | cut -d '(' -f 2 | cut -d ' ' -f 1)
echo -e "$DATE\t${num1}\t${num2}\t${num3}\t${num4}\t${num5}" >> ticket-type-all.txt
wget "http://trac.macports.org/query?status=new&status=assigned&status=reopened&component=ports" -O 10
wget "http://trac.macports.org/query?status=new&status=assigned&status=reopened&component=base" -O 11
num1=$(grep matches 10 | cut -d '(' -f 2 | cut -d ' ' -f 1)
num2=$(grep matches 11 | cut -d '(' -f 2 | cut -d ' ' -f 1)
echo -e "$DATE\t${num1}\t${num2}" >> ticket-component-all.txt
gnuplot ticket-status-all.plot
gnuplot ticket-type-all.plot
gnuplot ticket-component-all.plot
rm -f 1 2 3 4 5 6 7 8 9 10 11
YEAR=$(date +%Y)
for i in ticket-status ticket-type ticket-component; do
sed -e "s,@@YEAR@@,${YEAR},g" $i-ALL.plot > $i-${YEAR}.plot
grep -- ${YEAR}- $i-all.txt > $i-${YEAR}.txt
gnuplot $i-${YEAR}.plot
done