added commiters-per-month datset
This commit is contained in:
parent
7bfde589e2
commit
aa5dbff8d7
@ -704,11 +704,13 @@ class Code extends Controller
|
|||||||
$file = $this->subversion->getHistory ($projectid, $path, SVN_REVISION_HEAD);
|
$file = $this->subversion->getHistory ($projectid, $path, SVN_REVISION_HEAD);
|
||||||
if ($file === FALSE)
|
if ($file === FALSE)
|
||||||
{
|
{
|
||||||
header($_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error');
|
$history = array();
|
||||||
return;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$history = $file['history'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$history = $file['history'];
|
|
||||||
print codepot_json_encode ($history);
|
print codepot_json_encode ($history);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,26 +30,50 @@ function show_commits_per_month_graph(response)
|
|||||||
var log = $.parseJSON(response);
|
var log = $.parseJSON(response);
|
||||||
if (log == null)
|
if (log == null)
|
||||||
{
|
{
|
||||||
alert ('Invalid data ...');
|
alert ('Invalid data received');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var min_date = '9999-99', max_date = '0000-00';
|
var min_date = '9999-99', max_date = '0000-00';
|
||||||
var stats = [], stat_keys = [], stat_values = [];
|
var commits_per_month = [], commits_per_month_keys = [], commits_per_month_values = [];
|
||||||
|
var committers_per_month = [], committers_per_month_values = [], committer_list_per_month = [];
|
||||||
|
var commits_per_month_count = 0;
|
||||||
for (var i = 0; i < log.length; i++)
|
for (var i = 0; i < log.length; i++)
|
||||||
{
|
{
|
||||||
var date = log[i].date;
|
var date = log[i].date;
|
||||||
if (date)
|
if (date)
|
||||||
{
|
{
|
||||||
date = date.substring (0, 7);
|
date = date.substring (0, 7);
|
||||||
if (date in stats) stats[date]++;
|
if (date in commits_per_month) commits_per_month[date]++;
|
||||||
else stats[date] = 1;
|
else commits_per_month[date] = 1;
|
||||||
|
|
||||||
|
// TODO: calculate committers...
|
||||||
|
if (log[i].author)
|
||||||
|
{
|
||||||
|
committer_list_per_month[date + '-' + log[i].author] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (date < min_date) min_date = date;
|
if (date < min_date) min_date = date;
|
||||||
if (date > max_date) max_date = date;
|
if (date > max_date) max_date = date;
|
||||||
|
|
||||||
|
commits_per_month_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if (Object.keys(commits_per_month).length <= 0)
|
||||||
|
if (commits_per_month_count <= 0)
|
||||||
|
{
|
||||||
|
// no data to show
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var key in committer_list_per_month)
|
||||||
|
{
|
||||||
|
date = key.substring (0, 7);
|
||||||
|
if (date in committers_per_month) committers_per_month[date]++;
|
||||||
|
else committers_per_month[date] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
var year, month, min_year, max_year, min_month, max_month;
|
var year, month, min_year, max_year, min_month, max_month;
|
||||||
|
|
||||||
min_year = parseInt(min_date.substring (0, 4));
|
min_year = parseInt(min_date.substring (0, 4));
|
||||||
@ -57,6 +81,7 @@ function show_commits_per_month_graph(response)
|
|||||||
max_year = parseInt(max_date.substring (0, 4));
|
max_year = parseInt(max_date.substring (0, 4));
|
||||||
max_month = parseInt(max_date.substring (5));
|
max_month = parseInt(max_date.substring (5));
|
||||||
|
|
||||||
|
// fill empty data points
|
||||||
for (year = min_year; year <= max_year; year++)
|
for (year = min_year; year <= max_year; year++)
|
||||||
{
|
{
|
||||||
month = (year == min_year)? min_month: 1;
|
month = (year == min_year)? min_month: 1;
|
||||||
@ -72,39 +97,56 @@ function show_commits_per_month_graph(response)
|
|||||||
|
|
||||||
date = y + '-' + m;
|
date = y + '-' + m;
|
||||||
|
|
||||||
if (!(date in stats))
|
if (!(date in commits_per_month))
|
||||||
{
|
{
|
||||||
// fill the holes
|
// fill the holes
|
||||||
stats[date] = 0;
|
commits_per_month[date] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(date in committers_per_month))
|
||||||
|
{
|
||||||
|
// fill the holes
|
||||||
|
committers_per_month[date] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
month++;
|
month++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var key in stats)
|
// for sorting
|
||||||
|
for (var key in commits_per_month)
|
||||||
{
|
{
|
||||||
stat_keys.push (key);
|
commits_per_month_keys.push (key);
|
||||||
//stat_values.push (stats[key]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stat_keys = stat_keys.sort();
|
commits_per_month_keys = commits_per_month_keys.sort();
|
||||||
for (i = 0; i < stat_keys.length; i++)
|
for (i = 0; i < commits_per_month_keys.length; i++)
|
||||||
{
|
{
|
||||||
stat_values.push (stats[stat_keys[i]]);
|
commits_per_month_values.push (commits_per_month[commits_per_month_keys[i]]);
|
||||||
|
committers_per_month_values.push (committers_per_month[commits_per_month_keys[i]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var commits_per_month_data = {
|
var commits_per_month_data = {
|
||||||
labels : stat_keys,
|
labels : commits_per_month_keys,
|
||||||
|
|
||||||
datasets : [
|
datasets : [
|
||||||
{
|
{
|
||||||
label: 'Commits per month',
|
label: 'Commits per month',
|
||||||
fillColor : 'rgba(151,187,205,0.2)',
|
fillColor : 'rgba(151,187,205,0.2)',
|
||||||
strokeColor: "rgba(151,187,205,0.8)",
|
strokeColor: "rgba(151,187,205,0.8)",
|
||||||
data : stat_values
|
pointColor: "rgba(151,187,205,0.8)",
|
||||||
|
data : commits_per_month_values
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
label: 'Committers per month',
|
||||||
|
fillColor: "rgba(205,187,151,0.2)",
|
||||||
|
strokeColor: "rgba(205,187,151,0.8)",
|
||||||
|
pointColor: "rgba(205,187,151,0.8)",
|
||||||
|
data : committers_per_month_values
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#commits-per-month-canvas').each (function() {
|
$('#commits-per-month-canvas').each (function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user