From: Cédric Bosdonnat Date: Tue, 19 Apr 2011 08:50:19 +0000 (+0200) Subject: Made the CSV file aggregating data by weeks or months X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=92726d0df522d8a9acba039b874aa06c098c9ca0;p=people%2Flarsk%2Fxenproject-org-gitdm.git Made the CSV file aggregating data by weeks or months When using -w option together with the -x file option, the data exported in the CSV file are aggregated by weeks instead of months (the default). This is useful to extract meaningful stats on short periods. --- diff --git a/README b/README index 26cf81f..a5bdf63 100644 --- a/README +++ b/README @@ -55,6 +55,11 @@ be: -u Group all unknown developers under the "(Unknown)" employer. + -x file Export raw statistics as CSV. + + -w Aggregate the data by weeks instead of months in the + CSV file when -x is used. + -z Dump out the hacker database to "database.dump". A typical command line used to generate the "who write 2.6.x" LWN articles diff --git a/csv.py b/csv.py index 34ea10a..cec1f06 100644 --- a/csv.py +++ b/csv.py @@ -15,8 +15,10 @@ class CSVStat: PeriodCommitHash = { } -def AccumulatePatch (p): +def AccumulatePatch (p, Aggregate): date = "%.2d-%.2d-01"%(p.date.year, p.date.month) + if (Aggregate == 'week'): + date = "%.2d-%.2d"%(p.date.isocalendar()[0], p.date.isocalendar()[1]) authdatekey = "%s-%s"%(p.author.name, date) if authdatekey not in PeriodCommitHash: empl = p.author.emailemployer (p.email, p.date) diff --git a/gitdm b/gitdm index 47d1966..70f8138 100755 --- a/gitdm +++ b/gitdm @@ -36,6 +36,7 @@ AkpmOverLt = 0 DumpDB = 0 CFName = 'gitdm.config' DirName = '' +Aggregate = 'month' # # Options: @@ -52,14 +53,15 @@ DirName = '' # -s Ignore author SOB lines # -u Map unknown employers to '(Unknown)' # -x file.csv Export raw statistics as CSV +# -w Aggregrate the raw statistics by weeks instead of months # -z Dump out the hacker database at completion def ParseOpts (): global MapUnknown, DevReports global DateStats, AuthorSOBs, FileFilter, AkpmOverLt, DumpDB - global CFName, CSVFile, DirName + global CFName, CSVFile, DirName, Aggregate - opts, rest = getopt.getopt (sys.argv[1:], 'ab:dc:Dh:l:o:r:sux:z') + opts, rest = getopt.getopt (sys.argv[1:], 'a:b:dc:Dh:l:o:r:suwx:z') for opt in opts: if opt[0] == '-a': AkpmOverLt = 1 @@ -87,6 +89,8 @@ def ParseOpts (): elif opt[0] == '-x': CSVFile = open (opt[1], 'w') print "open output file " + opt[1] + "\n" + elif opt [0] == '-w': + Aggregate = 'week' elif opt[0] == '-z': DumpDB = 1 @@ -370,7 +374,7 @@ while (1): for hacker in p.reports: hacker.addreport (p) CSCount += 1 - csv.AccumulatePatch (p) + csv.AccumulatePatch (p, Aggregate) print >> sys.stderr, 'Grabbing changesets...done ' if DumpDB: