SVN: toys/cvsstats: count.sql generate.sh

pawelz pawelz at pld-linux.org
Thu Apr 1 00:59:44 CEST 2010


Author: pawelz
Date: Thu Apr  1 00:59:43 2010
New Revision: 11290

Added:
   toys/cvsstats/count.sql
   toys/cvsstats/generate.sh   (contents, props changed)
Log:
- scripts for generating stats from database


Added: toys/cvsstats/count.sql
==============================================================================
--- (empty file)
+++ toys/cvsstats/count.sql	Thu Apr  1 00:59:43 2010
@@ -0,0 +1,86 @@
+-- First of all copy commits FROM last month to separate table
+
+DROP TABLE IF EXISTS commits_ at Y@_ at M@;
+DROP TABLE IF EXISTS files_ at Y@_ at M@;
+
+CREATE TABLE commits_ at Y@_ at M@ (
+	author VARCHAR(255),
+	date DATETIME,
+	tag VARCHAR(255),
+	files INTEGER,
+	hunks INTEGER,
+	added INTEGER,
+	removed INTEGER
+);
+
+CREATE TABLE files_ at Y@_ at M@ (
+	filename VARCHAR(255),
+	date DATETIME,
+	author VARCHAR(255),
+	tag VARCHAR(255),
+	hunks INTEGER,
+	added INTEGER,
+	removed INTEGER
+);
+
+INSERT INTO files_ at Y@_ at M@ SELECT * FROM files WHERE date LIKE '@Y at -@M at -%';
+INSERT INTO commits_ at Y@_ at M@ SELECT * FROM commits WHERE date LIKE '@Y at -@M at -%';
+
+
+SELECT('----');
+SELECT('Total number of commits:');
+SELECT count(*) FROM commits_ at Y@_ at M@;
+
+SELECT('----');
+SELECT('Number of touched files:');
+SELECT count(distinct filename) FROM files_ at Y@_ at M@;
+
+SELECT('----');
+SELECT('Number of authors that commited at least once:');
+SELECT count(distinct author) FROM commits_ at Y@_ at M@;
+
+SELECT('----');
+SELECT('Number of hunks:');
+SELECT sum(hunks) FROM commits_ at Y@_ at M@;
+
+SELECT('----');
+SELECT('Number of added lines:');
+SELECT sum(added) FROM commits_ at Y@_ at M@;
+
+SELECT('----');
+SELECT('Number of removed lines:');
+SELECT sum(removed) FROM commits_ at Y@_ at M@;
+
+SELECT('----');
+SELECT('Number of commits per author:');
+SELECT author, count(*) AS `Number of commits` FROM commits_ at Y@_ at M@ GROUP BY author ORDER BY `Number of commits` DESC LIMIT 3;
+
+SELECT('----');
+SELECT('Most hard-working developers (in terms of numbers of changed lines in their commits) were:');
+SELECT author, sum(added)+sum(removed) AS `Number of changed lines`, sum(added), sum(removed) FROM commits_ at Y@_ at M@ GROUP BY author ORDER BY `Number of changed lines` DESC LIMIT 3;
+
+SELECT('----');
+SELECT('Most creative developers (numbers of added lines/number of removed lines) were:');
+SELECT author, sum(added)/sum(removed) AS `Points`, sum(added), sum(removed) FROM commits_ at Y@_ at M@ GROUP BY author ORDER BY `Points` DESC LIMIT 3;
+
+SELECT('----');
+SELECT('Most destructive developers (same as above, but bottom three) were:');
+SELECT author, sum(added)/sum(removed) AS `Points`, sum(added), sum(removed) FROM commits_ at Y@_ at M@ GROUP BY author ORDER BY `Points` ASC LIMIT 3;
+
+SELECT('----');
+SELECT('Most actively developed files (in terms of number of commits) were:');
+SELECT filename, count(*) AS `Number of commits` FROM files_ at Y@_ at M@ GROUP BY filename ORDER BY `Number of commits` DESC LIMIT 20;
+
+SELECT('----');
+SELECT('Most changed files (in terms of modified lines) were:');
+SELECT filename, sum(added) + sum(removed) AS `Changed lines` FROM files_ at Y@_ at M@ GROUP BY filename ORDER BY `Changed lines` DESC LIMIT 20;
+
+SELECT('----');
+SELECT('Number of commits per author (full table):');
+SELECT author, count(*) AS `Number of commits` FROM commits_ at Y@_ at M@ GROUP BY author ORDER BY `Number of commits` DESC;
+
+SELECT('----');
+SELECT('Most hard-working developers (full table):');
+SELECT author, sum(added)+sum(removed) AS `Number of changed lines`, sum(added), sum(removed) FROM commits_ at Y@_ at M@ GROUP BY author ORDER BY `Number of changed lines` DESC;
+
+-- vim:tabstop=2

Added: toys/cvsstats/generate.sh
==============================================================================
--- (empty file)
+++ toys/cvsstats/generate.sh	Thu Apr  1 00:59:43 2010
@@ -0,0 +1,11 @@
+#!/bin/sh
+if [ '$#' != 2 ]; then
+  echo "Usage: $0 YYYY MM"
+  exit
+fi
+
+YEAR=$1
+MONTH=$2
+
+sed -e "s, at Y@,$MONTH,g;s, at M@,$YEAR,g" < count.sql \
+  | mysql -upldstats -p pldstats -t > statystyki-$YEAR-$MONTH


More information about the pld-cvs-commit mailing list