enhanced the commits-per-month graph

This commit is contained in:
hyung-hwan 2015-02-08 05:00:19 +00:00
parent d12de4e0cf
commit 4fc812ef91
10 changed files with 2562 additions and 1745 deletions

View File

@ -2,7 +2,7 @@ Package: @PACKAGE@
Version: @VERSION@ Version: @VERSION@
Maintainer: @PACKAGE_BUGREPORT@ Maintainer: @PACKAGE_BUGREPORT@
Homepage: @PACKAGE_URL@ Homepage: @PACKAGE_URL@
Depends: subversion, apache2-mpm-prefork, libapache2-svn, php5, php5-ldap, wget Depends: subversion, apache2-mpm-prefork, libapache2-svn, php5, php5-ldap, php5-gd
Recommends: php5-mysql, php5-svn (>= 0.5.1) Recommends: php5-mysql, php5-svn (>= 0.5.1)
Suggests: slapd, mysql-server Suggests: slapd, mysql-server
Section: web Section: web

View File

@ -6,6 +6,7 @@
[ -d "@DEPOTDIR@/svnrepo" ] || { mkdir -p "@DEPOTDIR@/svnrepo" && svnrepodir=1; } [ -d "@DEPOTDIR@/svnrepo" ] || { mkdir -p "@DEPOTDIR@/svnrepo" && svnrepodir=1; }
[ -d "@DEPOTDIR@/files" ] || { mkdir -p "@DEPOTDIR@/files" && filesdir=1; } [ -d "@DEPOTDIR@/files" ] || { mkdir -p "@DEPOTDIR@/files" && filesdir=1; }
[ -d "@DEPOTDIR@/attachments" ] || { mkdir -p "@DEPOTDIR@/attachments" && attachmentsdir=1; } [ -d "@DEPOTDIR@/attachments" ] || { mkdir -p "@DEPOTDIR@/attachments" && attachmentsdir=1; }
[ -d "@DEPOTDIR@/usericons" ] || { mkdir -p "@DEPOTDIR@/usericons" && usericonsdir=1; }
[ -f "@SYSCONFDIR@/apache2/envvars" ] && { [ -f "@SYSCONFDIR@/apache2/envvars" ] && {
GROUP=$(. "@SYSCONFDIR@/apache2/envvars" && echo "${APACHE_RUN_GROUP}") GROUP=$(. "@SYSCONFDIR@/apache2/envvars" && echo "${APACHE_RUN_GROUP}")
@ -30,6 +31,10 @@
chgrp -R "${GROUP}" "@DEPOTDIR@/attachments" chgrp -R "${GROUP}" "@DEPOTDIR@/attachments"
chmod 0775 "@DEPOTDIR@/attachments" chmod 0775 "@DEPOTDIR@/attachments"
} }
[ "${usericonsdir}" = "1" ] && {
chgrp -R "${GROUP}" "@DEPOTDIR@/usericons"
chmod 0775 "@DEPOTDIR@/usericons"
}
} }
} }

View File

@ -5,6 +5,7 @@
[ -d "@DEPOTDIR@/svnrepo" ] && rmdir "@DEPOTDIR@/svnrepo" 2>/dev/null [ -d "@DEPOTDIR@/svnrepo" ] && rmdir "@DEPOTDIR@/svnrepo" 2>/dev/null
[ -d "@DEPOTDIR@/files" ] && rmdir "@DEPOTDIR@/files" 2>/dev/null [ -d "@DEPOTDIR@/files" ] && rmdir "@DEPOTDIR@/files" 2>/dev/null
[ -d "@DEPOTDIR@/attachments" ] && rmdir "@DEPOTDIR@/attachments" 2>/dev/null [ -d "@DEPOTDIR@/attachments" ] && rmdir "@DEPOTDIR@/attachments" 2>/dev/null
[ -d "@DEPOTDIR@/usericons" ] && rmdir "@DEPOTDIR@/usericons" 2>/dev/null
[ -d "@DEPOTDIR@" ] && rmdir "@DEPOTDIR@" 2>/dev/null [ -d "@DEPOTDIR@" ] && rmdir "@DEPOTDIR@" 2>/dev/null
exit 0 exit 0

View File

@ -29,7 +29,6 @@ INSTALLATION
Here is how to install Codepot into the standard locations under Ubuntu Linux. Here is how to install Codepot into the standard locations under Ubuntu Linux.
* Install required packages. * Install required packages.
$ sudo apt-get install wget
$ sudo apt-get install subversion $ sudo apt-get install subversion
$ sudo apt-get install apache2-mpm-prefork $ sudo apt-get install apache2-mpm-prefork
$ sudo apt-get install libapache2-svn $ sudo apt-get install libapache2-svn

View File

@ -15,6 +15,9 @@
/* Define to the one symbol short name of this package. */ /* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME #undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */ /* Define to the version of this package. */
#undef PACKAGE_VERSION #undef PACKAGE_VERSION

4136
codepot/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -788,6 +788,10 @@ class Code extends Controller
} }
else if ($type == 'commits-per-month') else if ($type == 'commits-per-month')
{ {
$total_commits = 0;
$average_commits = 0;
$total_months = 0;
$file = $this->subversion->getHistory ($projectid, $path, SVN_REVISION_HEAD); $file = $this->subversion->getHistory ($projectid, $path, SVN_REVISION_HEAD);
if ($file === FALSE) if ($file === FALSE)
{ {
@ -796,7 +800,7 @@ class Code extends Controller
$stats = array ('no-data' => 0); $stats = array ('no-data' => 0);
} }
else else
{ {
$history = $file['history']; $history = $file['history'];
$history_count = count($history); $history_count = count($history);
@ -833,9 +837,12 @@ class Code extends Controller
$max_month = substr($k, 5, 2); $max_month = substr($k, 5, 2);
} }
$idx++; $idx++;
$total_commits += $v;
} }
$total_months = 0;
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;
@ -852,23 +859,30 @@ class Code extends Controller
} }
$month++; $month++;
$total_months++;
} }
} }
if ($total_months > 0) $average_commits = $total_commits / $total_months;
} }
ksort ($stats); ksort ($stats);
$stats_count = count($stats); $stats_count = count($stats);
$graph_width = $stats_count * 5; $graph_width = $stats_count * 8;
if ($graph_width < 400) $graph_width = 400; if ($graph_width < 400) $graph_width = 400;
$this->load->library ('PHPGraphLib', array ('width' => $graph_width, 'height' => 150), 'graph'); $this->load->library ('PHPGraphLib', array ('width' => $graph_width, 'height' => 180), 'graph');
$this->graph->addData($stats); $this->graph->addData($stats);
$this->graph->setTitle('Commits per month'); $this->graph->setTitle("Commits per month ({$total_commits}/{$total_months})");
$this->graph->setDataPoints(FALSE); $this->graph->setDataPoints(FALSE);
$this->graph->setDataValues(FALSE); $this->graph->setDataValues(FALSE);
$this->graph->setLine(TRUE); $this->graph->setLine(FALSE);
$this->graph->setLineColor("red"); $this->graph->setLineColor("red");
$this->graph->setBars(FALSE); $this->graph->setBars(TRUE);
$this->graph->setBarOutline (TRUE);
$this->graph->setBarColor ("#EEEEEE");
$this->graph->setBarOutlineColor ("#AAAAAA");
$this->graph->setBarSpace(FALSE);
$this->graph->setXValues(TRUE); $this->graph->setXValues(TRUE);
$this->graph->setXValuesHorizontal(TRUE); $this->graph->setXValuesHorizontal(TRUE);
if ($stats_count < 12) if ($stats_count < 12)
@ -883,7 +897,10 @@ class Code extends Controller
{ {
$this->graph->setXValuesInterval(11); $this->graph->setXValuesInterval(11);
} }
$this->graph->setGrid(FALSE); //$this->graph->setGrid(FALSE);
$this->graph->setGridVertical(FALSE);
$this->graph->setGridHorizontal(TRUE);
if ($total_months > 0) $this->graph->setGoalLine ($average_commits, "red", "solid");
$this->graph->createGraph(); $this->graph->createGraph();
} }
else if ($type == 'commit-share-by-users') else if ($type == 'commit-share-by-users')

View File

@ -84,7 +84,9 @@ class PHPGraphLib {
protected $bool_y_axis = true; protected $bool_y_axis = true;
protected $bool_x_axis_values = true; protected $bool_x_axis_values = true;
protected $bool_y_axis_values = true; protected $bool_y_axis_values = true;
protected $bool_grid = true; //protected $bool_grid = true;
protected $bool_grid_horizontal = true;
protected $bool_grid_vertical = true;
protected $bool_line = false; protected $bool_line = false;
protected $bool_data_values = false; protected $bool_data_values = false;
protected $bool_x_axis_values_vert = true; protected $bool_x_axis_values_vert = true;
@ -145,6 +147,7 @@ class PHPGraphLib {
protected $data_format_generic; protected $data_format_generic;
//bar vars / scale //bar vars / scale
protected $bool_bar_space = TRUE;
protected $bar_width; protected $bar_width;
protected $space_width; protected $space_width;
protected $unit_scale; protected $unit_scale;
@ -294,16 +297,26 @@ class PHPGraphLib {
protected function setupData() protected function setupData()
{ {
$unit_width = ($this->width - $this->y_axis_margin - $this->right_margin) / (($this->data_count * 2) + $this->data_count); if ($this->bool_bar_space)
if ($unit_width < 1 && !$this->bool_ignore_data_fit_errors) { {
$unit_width = ($this->width - $this->y_axis_margin - $this->right_margin) / (($this->data_count * 2) + $this->data_count);
}
else
{
$unit_width = ($this->width - $this->y_axis_margin - $this->right_margin) / (($this->data_count * 2));
}
if ($unit_width < 1 && !$this->bool_ignore_data_fit_errors) {
//error units too small, too many data points or not large enough graph //error units too small, too many data points or not large enough graph
$this->bool_bars_generate = false; $this->bool_bars_generate = false;
$this->error[] = "Graph too small or too many data points."; $this->error[] = "Graph too small or too many data points.";
} else { } else {
//default space between bars is 1/2 the width of the bar //default space between bars is 1/2 the width of the bar
//find bar and space widths. bar = 2 units, space = 1 unit //find bar and space widths. bar = 2 units, space = 1 unit
$this->bar_width = 2 * $unit_width; $this->bar_width = 2 * $unit_width;
$this->space_width = $unit_width; $this->space_width = ($this->bool_bar_space)? $unit_width: 0;
//now calculate height (scale) units //now calculate height (scale) units
$availVertSpace = $this->height - $this->x_axis_margin - $this->top_margin; $availVertSpace = $this->height - $this->x_axis_margin - $this->top_margin;
if ($availVertSpace < 1) { if ($availVertSpace < 1) {
@ -391,9 +404,14 @@ class PHPGraphLib {
foreach ($this->data_array as $data_set_num => $data_set) { foreach ($this->data_array as $data_set_num => $data_set) {
$lineX2 = null; $lineX2 = null;
$xStart = $this->y_axis_x1 + ($this->space_width / 2); $xStart = $this->y_axis_x1 + ($this->space_width / 2);
$y1 = 0;
$y2 = 0;
foreach ($data_set as $key => $item) { foreach ($data_set as $key => $item) {
$hideBarOutline = false; $hideBarOutline = false;
$old_y1 = $y1;
$old_y2 = $y2;
$x1 = round($xStart + ($dataset_offset * $data_set_num)); $x1 = round($xStart + ($dataset_offset * $data_set_num));
$x2 = round(($xStart + $this->bar_width) + ($dataset_offset * $data_set_num)); $x2 = round(($xStart + $this->bar_width) + ($dataset_offset * $data_set_num));
$y1 = round($this->x_axis_y1 - ($item * $this->unit_scale) + $adjustment); $y1 = round($this->x_axis_y1 - ($item * $this->unit_scale) + $adjustment);
@ -418,10 +436,21 @@ class PHPGraphLib {
} else { } else {
imagefilledrectangle($this->image, $x1, $y1,$x2, $y2, $this->multi_bar_colors[$data_set_num]); imagefilledrectangle($this->image, $x1, $y1,$x2, $y2, $this->multi_bar_colors[$data_set_num]);
} }
//draw bar outline //draw bar outline
if ($this->bool_bar_outline && !$hideBarOutline) { if ($this->bool_bar_outline && !$hideBarOutline) {
imagerectangle($this->image, $x1, $y2, $x2, $y1, $this->outline_color);
if ($this->bool_bar_space)
{
imagerectangle($this->image, $x1, $y2, $x2, $y1, $this->outline_color);
}
else
{
imageline ($this->image, $x1, $old_y1, $x1, $y1, $this->outline_color);
imageline ($this->image, $x1, $y1, $x2, $y1, $this->outline_color);
}
} }
} }
// draw line // draw line
if ($this->bool_line) { if ($this->bool_line) {
@ -434,7 +463,7 @@ class PHPGraphLib {
} else { } else {
$lineX2 = $lineX1; $lineX2 = $lineX1;
$lineY2 = $lineY1; $lineY2 = $lineY1;
} }
} }
// display data points // display data points
if ($this->bool_data_points) { if ($this->bool_data_points) {
@ -522,6 +551,13 @@ class PHPGraphLib {
} }
} }
} }
if ($this->bool_bar_outline && !$hideBarOutline && !$this->bool_bar_space)
{
imageline ($this->image, $x2, $y1, $x2, $y2, $this->outline_color);
}
$xStart += $this->bar_width + $this->space_width; $xStart += $this->bar_width + $this->space_width;
} }
} }
@ -699,7 +735,8 @@ class PHPGraphLib {
//loop through each horizontal line //loop through each horizontal line
foreach ($horizGridArray as $value) { foreach ($horizGridArray as $value) {
$yValue = round($this->x_axis_y1 - ($value * $this->unit_scale) + $adjustment); $yValue = round($this->x_axis_y1 - ($value * $this->unit_scale) + $adjustment);
if ($this->bool_grid) { //if ($this->bool_grid) {
if ($this->bool_grid_horizontal) {
//imageline($this->image, $this->y_axis_x1, $yValue, $this->x_axis_x2 , $yValue, $this->grid_color); //imageline($this->image, $this->y_axis_x1, $yValue, $this->x_axis_x2 , $yValue, $this->grid_color);
$this->horiz_grid_lines[] = array('x1' => $this->y_axis_x1, 'y1' => $yValue, $this->horiz_grid_lines[] = array('x1' => $this->y_axis_x1, 'y1' => $yValue,
'x2' => $this->x_axis_x2, 'y2' => $yValue, 'color' => $this->grid_color); 'x2' => $this->x_axis_x2, 'y2' => $yValue, 'color' => $this->grid_color);
@ -740,7 +777,8 @@ class PHPGraphLib {
} }
//loop through each vertical line //loop through each vertical line
if ($this->bool_grid) { //if ($this->bool_grid) {
if ($this->bool_grid_vertical) {
$xValue = $this->y_axis_y1; $xValue = $this->y_axis_y1;
foreach ($vertGridArray as $value) { foreach ($vertGridArray as $value) {
//imageline($this->image, $value, $this->y_axis_y2, $value, $xValue , $this->grid_color); //imageline($this->image, $value, $this->y_axis_y2, $value, $xValue , $this->grid_color);
@ -1101,10 +1139,39 @@ class PHPGraphLib {
} }
} }
public function setBarSpace ($bool)
{
if (is_bool($bool)) {
$this->bool_bar_space = $bool;
} else {
$this->error[] = "Value arg for setBarSpace() not specified properly.";
}
}
public function setGrid($bool) public function setGrid($bool)
{ {
if (is_bool($bool)) { if (is_bool($bool)) {
$this->bool_grid = $bool; //$this->bool_grid = $bool;
$this->bool_grid_horizontal = $bool;
$this->bool_grid_vertical = $bool;
} else {
$this->error[] = "Boolean arg for setGrid() not specified properly.";
}
}
public function setGridHorizontal($bool)
{
if (is_bool($bool)) {
$this->bool_grid_horizontal = $bool;
} else {
$this->error[] = "Boolean arg for setGrid() not specified properly.";
}
}
public function setGridVertical($bool)
{
if (is_bool($bool)) {
$this->bool_grid_vertical = $bool;
} else { } else {
$this->error[] = "Boolean arg for setGrid() not specified properly."; $this->error[] = "Boolean arg for setGrid() not specified properly.";
} }

View File

@ -270,6 +270,18 @@ class ProjectModel extends Model
if ($force) if ($force)
{ {
$this->db->where ('projectid', $project->id);
$query = $this->db->get ('wiki_attachment');
if ($this->db->trans_status() === FALSE)
{
$this->db->trans_rollback ();
return FALSE;
}
$wikiatts = $query->result ();
$this->db->where ('projectid', $project->id);
$this->db->delete ('wiki_attachment');
$this->db->where ('projectid', $project->id); $this->db->where ('projectid', $project->id);
$this->db->delete ('wiki'); $this->db->delete ('wiki');
@ -279,6 +291,9 @@ class ProjectModel extends Model
$this->db->where ('projectid', $project->id); $this->db->where ('projectid', $project->id);
$this->db->delete ('issue'); $this->db->delete ('issue');
$this->db->where ('projectid', $project->id);
$this->db->delete ('code_review');
$this->db->where ('projectid', $project->id); $this->db->where ('projectid', $project->id);
$query = $this->db->get ('file'); $query = $this->db->get ('file');
if ($this->db->trans_status() === FALSE) if ($this->db->trans_status() === FALSE)
@ -287,7 +302,7 @@ class ProjectModel extends Model
return FALSE; return FALSE;
} }
$result = $query->result (); $files = $query->result ();
$this->db->where ('projectid', $project->id); $this->db->where ('projectid', $project->id);
$this->db->delete ('file'); $this->db->delete ('file');
@ -319,11 +334,21 @@ class ProjectModel extends Model
} }
else else
{ {
if ($force && count($result) > 0) if ($force)
{ {
// no way to roll back file delete. if (count($files) > 0)
// so deletion is done here. {
$this->_delete_files_uploaded ($result); // no way to roll back file delete.
// so deletion is done here.
$this->_delete_files (CODEPOT_FILE_DIR, $files);
}
if (count($wikiatts) > 0)
{
// no way to roll back attachment delete.
// so deletion is done here.
$this->_delete_files (CODEPOT_ATTACHMENT_DIR, $wikiatts);
}
} }
$this->db->trans_commit (); $this->db->trans_commit ();
@ -455,10 +480,10 @@ class ProjectModel extends Model
return ($count == 1)? TRUE: FALSE; return ($count == 1)? TRUE: FALSE;
} }
function _delete_files_uploaded ($files) function _delete_files ($basedir, $files)
{ {
foreach ($files as $file) foreach ($files as $file)
@unlink (CODEPOT_FILE_DIR . "/{$file->encname}"); @unlink ($basedir . "/{$file->encname}");
} }
function getUserIcons ($users) function getUserIcons ($users)

View File

@ -16,7 +16,7 @@
<?php $review_count = count($reviews); ?> <?php $review_count = count($reviews); ?>
<?php $is_loggedin = ($login['id'] != ''); ?> <?php $is_loggedin = ($login['id'] != ''); ?>
<?php $can_edit = ($login['id'] == $file['history']['author']); ?> <?php $can_edit = ($is_loggedin && $login['id'] == $file['history']['author']); ?>
<?php if ($can_edit): ?> <?php if ($can_edit): ?>
$(function() { $(function() {