diff --git a/src/IDF/Views.php b/src/IDF/Views.php index 2ad660d..e79b510 100644 --- a/src/IDF/Views.php +++ b/src/IDF/Views.php @@ -40,9 +40,11 @@ class IDF_Views public function index($request, $match) { $projects = self::getProjects($request->user); + $stats = self::getProjectsStatistics ($projects); return Pluf_Shortcuts_RenderToResponse('idf/index.html', array('page_title' => __('Projects'), - 'projects' => $projects), + 'projects' => $projects, + 'stats' => new Pluf_Template_ContextVars($stats)), $request); } @@ -343,4 +345,41 @@ class IDF_Views return Pluf::factory('IDF_Project')->getList(array('filter' => $sql, 'order' => 'name ASC')); } -} \ No newline at end of file + + /** + * Returns statistics on a list of projects. + * + * @param ArrayObject IDF_Project + * @return Associative array of statistics + */ + public static function getProjectsStatistics($projects) + { + // Init the return var + $forgestats = array('downloads' => 0, + 'reviews' => 0, + 'issues' => 0, + 'docpages' => 0, + 'commits' => 0); + + // Count for each projects + foreach ($projects as $p) { + $pstats = $p->getStats (); + $forgestats['downloads'] += $pstats['downloads']; + $forgestats['reviews'] += $pstats['reviews']; + $forgestats['issues'] += $pstats['issues']; + $forgestats['docpages'] += $pstats['docpages']; + $forgestats['commits'] += $pstats['commits']; + } + + // Count projects + $forgestats['projects'] = count($projects); + + // Count members + $db =& Pluf::db(); + $sql = "SELECT count(id) as `nb` FROM indefero_users WHERE first_name != '---'"; + $ret = $db->select ($sql); + $forgestats['members'] = $ret[0]['nb']; + + return $forgestats; + } +} diff --git a/src/IDF/templates/idf/index.html b/src/IDF/templates/idf/index.html index 5d66fd6..072e7ae 100644 --- a/src/IDF/templates/idf/index.html +++ b/src/IDF/templates/idf/index.html @@ -1,5 +1,5 @@ {extends "idf/base-simple.html"} -{block docclass}yui-t1{/block} +{block docclass}yui-t2{/block} {block tabhome} class="active"{/block} {block subtabs}{trans 'Projects'}{/block} {block body} @@ -15,6 +15,17 @@ {/if} {/block} {block context} -

{trans 'Managed Projects:'} {$projects.count()}

+
+

Forge statistics

+ + + + + + + + +
{trans 'Projects:'}{$stats.projects}
{trans 'Members:'}{$stats.members}
{trans 'Issues:'}{$stats.issues}
{trans 'Commits:'}{$stats.commits}
{trans 'Documentations:'}{$stats.docpages}
{trans 'Downloads:'}{$stats.downloads}
{trans 'Code reviews:'}{$stats.reviews}
+
{/block} {block foot}
Powered by InDefero,
a CĂ©ondo Ltd initiative.
{/block} diff --git a/www/media/idf/css/style.css b/www/media/idf/css/style.css index 1e6cafe..b8fa632 100644 --- a/www/media/idf/css/style.css +++ b/www/media/idf/css/style.css @@ -994,3 +994,18 @@ span.scm-action.renamed { span.scm-action.property-changed { background-color: blue; } + +/* + * Stats on index + */ +#stats > h3 { + text-decoration : underline; +} + +#stats table tr td { + border-style: none; +} + +#stats td { + padding: .2em; +}