#!/usr/bin/env python
# Copyright 2007 Kees Cook <kees@ubuntu.com>
# License: GPLv2

print '''
set xdata time
set timefmt "%s"
set xtics rotate by 90
set xlabel "Date/Time" 0,-1

set ylabel "Number of Bugs"

set term png small size 400,300
set grid
set key top left
'''

statinfo = {
    'fixed': { 'title':'Fixes uploaded', 'column':2 },
    }

days = {
    'month': { 'step': 24, 'span': 3600*24*30, 'format': '%d %b' },
    }

data = open('bugstats.data')
start = int(data.readline().split(",")[0])
data.close()

for day in days.keys():
    xmin = start
    for stat in statinfo.keys():
        print '''
set format x "%s"
set output "plots/%s-%s.png"
plot ["%d":] "bugstats.data" using 1:%d title "%s" with linespoints pointtype 6 pointsize 0.5, "< tail -n 1 bugstats.data" using 1:%d notitle with points pointtype 6
''' % (days[day]['format'], day, stat, xmin, statinfo[stat]['column'], statinfo[stat]['title'], statinfo[stat]['column'])
