};
+ //print(JSON.stringify(lines,null,4));
+
// summarize data...
var hours = {};
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
- var hour = hours[line].start.format('H');
+ var hour = line.start.format('H');
+ var project = line.project;
hours[hour] = (typeof(hours[hour]) == 'undefined') ? {} : hours[hour];
- hours[hour][project] = (typeof(hours[project]) == 'undefined') ?
+ hours[hour][project] = (typeof(hours[hour][project]) == 'undefined') ?
{ total : 0, items : [] }
- : hours[project];
+ : hours[hour][project];
hours[hour][project].total += line.span;
hours[hour][project].items.push(line);
}
},
parseLine : function(l)
{
- var ret = { cmd : false, line : l };
+ var ret = { cmd : false, line : l, span : 0 };
var ar = l.split(/\s+/);
- print(JSON.stringify(ar));
+ //print(JSON.stringify(ar));
var time = ar.shift();
- print(time);
+ //print("time: " + time);
ret.start = xDate.Date.parseDate(this.date.format('Y-m-d') + ' ' + time, 'Y-m-d H:i:s');
+
-
- while (ret.cmd !== false) {
+ while (ret.cmd === false) {
var ta = ar.pop();
+ //print("TA:"+ta)
if (ta[0] != '-') { //hopfully withc catch stuff.
ret.cmd = ta;
break;
}
if (!ar.length) {
// just assume it's the last bit..
- print(line);
+ //print(line);
throw "invalid line: " + l;
}
}
+ //print(ret.cmd);
ret.title = ar.join(' ');
if (typeof(this[ret.cmd])=='undefined') {
- throw "Unknown application: " + ret.line;
+ ret.project = 'Unknown';
+ return ret;
+ print( "Unknown application: " + ret.line);
+ throw { error : "TEST"};
}
if (typeof(this[ret.cmd])=='string') {
ret.project = this[ret.cmd]
return ret;
},
-
+
'/usr/bin/perl' : function(ret) {
if (ret.title.match(/^PAC/)) {
ret.project = 'Unknown';
},
'/usr/lib/Komodo-Edit-7/lib/mozilla/komodo' : function(ret) {
- var l = ret.title.match(/Project\s+(^\)+)/);
- print(l);
-
- throw "Unknown match: " + ret.line;
+ var l = ret.title.match(/Project\s+(^\)+)/);
+ if (!l) {
+ ret.project="Unknown";
+ return;
+ }
+ throw "Unknown match: " + ret.line;
},
'guake' : 'Local Terminal',
-
+ 'mono' : 'mono?'
+
}
var res = GitLogParser.parse(xDate.Date.parseDate('2012-07-31', 'Y-m-d'));
-print(JSON.stringify(res,null,4));
+for (var h in res) {
+ for (var p in res[h]) {
+ if (p == 'IDLE') {
+ print(h + ' ' + Math.floor(res[h][p].total/60000) +') IDLE' );
+ continue;
+ }
+ print(h + ' ' + Math.floor(res[h][p].total/60000) +'m ' + p );
+
+ for (var k in res[h][p].items) {
+
+ print( ' ' + Math.floor(res[h][p].items[k].span/60000) +'m ' + res[h][p].items[k].line );
+
+ }
+
+
+ }
+
+}
+//print(JSON.stringify(res,null,4));
// open file..