summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedricbosdo@openoffice.org>2011-04-19 10:50:19 +0200
committerJonathan Corbet <corbet@lwn.net>2011-04-22 08:43:41 -0600
commit92726d0df522d8a9acba039b874aa06c098c9ca0 (patch)
treece4b80e294c836a544f8450dd5288df822269ee1
parentc1f096042b9eb22da2c1e796101741e8d22c0875 (diff)
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.
-rw-r--r--README5
-rw-r--r--csv.py4
-rwxr-xr-xgitdm10
3 files changed, 15 insertions, 4 deletions
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: