]> xenbits.xensource.com Git - people/larsk/xenproject-org-gitdm.git/commitdiff
Made the CSV file aggregating data by weeks or months
authorCédric Bosdonnat <cedricbosdo@openoffice.org>
Tue, 19 Apr 2011 08:50:19 +0000 (10:50 +0200)
committerJonathan Corbet <corbet@lwn.net>
Fri, 22 Apr 2011 14:43:41 +0000 (08:43 -0600)
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.

README
csv.py
gitdm

diff --git a/README b/README
index 26cf81f75b9151b60488d3e3f835aa50ee7f6cf1..a5bdf638d1cf5fcf8c6a2dcb3cd8ac3e0024a0f7 100644 (file)
--- 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 34ea10aba6b91f0b0f751707feaccc350b848b6f..cec1f063b02d83765f4bd74b1635fd0807e9ce46 100644 (file)
--- 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 47d19669f152e6f25daf69321e320c883a88a8cc..70f813885f63ce903534f549b3f59bb7d20a3474 100755 (executable)
--- 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: