blob: b7bdcb045f1c456d0df8b2db467c386a9869a48f [file] [log] [blame]
<?php
/**
* *****************************************************************************
* Copyright (c) 2018 Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* *****************************************************************************
*/
require_once ($_SERVER ['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php");
require_once ($_SERVER ['DOCUMENT_ROOT'] . "/eclipse.org-common/system/nav.class.php");
require_once ($_SERVER ['DOCUMENT_ROOT'] . "/eclipse.org-common/system/menu.class.php");
$App = new App ();
$Nav = new Nav ();
$Menu = new Menu ();
include ($App->getProjectCommon ());
require_once $_SERVER ['DOCUMENT_ROOT'] . '/projects/classes/Project.class.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/projects/classes/ProjectStatusReporter.class.inc';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/projects/classes/debug.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/projects/classes/database.inc';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/projects/classes/common.php';
require_once dirname(__FILE__) . '/charts.inc';
mustBeCommitter();
$pageTitle = "Eclipse Project Overview";
$pageKeywords = "";
$pageAuthor = "Wayne Beaton";
ob_start ();
if (!(($id = @$_GET['id']) && isValidProjectId($id))) $id = null;
if (!$age = (int)@$_GET['ago']) $age = 24;
function selectTopLevelProject($url = '', $key = 'id') {
echo "<ul>";
foreach(Project::getTopLevelProjects() as $project) {
echo "<li><a href=\"{$url}?{$key}={$project->getId()}\">{$project->getName()}</a></li>";
}
echo "</ul>";
}
?>
<div id="maincontent">
<div id="midcolumn">
<h1><?=$pageTitle?></h1>
<p>EXPERIMENTAL. This page shows some basic metrics.</p>
<?php
if ($project) {
$sql = "
select
p.subproject as project,
count(distinct gc.ref) as commits,
max(gc.date) as last
from ProjectRollup as p
left join GitRepo as gr on p.subproject=gr.project
left join GitCommit as gc on gr.path=gc.path
and gc.date > date(':start')
where p.project = ':id'
group by p.subproject
";
$arguments = array(
':id' => $id,
':start' => date('Y-m-d', strtotime("- $age months"))
);
query('dashboard', $sql, $arguments, function($row) use ($age) {
$project = Project::getProject($row['project']);
if ($project) {
$status = new ProjectStatusReporter(array($project->getId()));
echo "<h2><a href=\"?id={$project->getId()}&ago=$age\">{$project->getName()}</a></h2>";
echo "<div style=\"margin-left:1em\">";
echo "<h3>Lifetime stats</h3>";
echo "<div class=\"container\">";
$status->values($project->getId(), function($column) use (&$lines) {
echo "<div class=\"row\"><div class=\"col-md-6\">{$column->getTitle()}:</div><div class=\"col-md-6\">{$column->getValue()}</div></div>";
});
echo "</div>";
ChartBuilder::named("project_activity_" . rand())
->title("Commit Activity")
->description(
"Overall committer activity by month based on commits made against
project repositories.
This excludes the current month.")
->query('dashboard', "
select
periods.period as period,
if (commits.count is null, 0, commits.count) as count
from (
select distinct period
from ProjectCommitActivity
where
period
between (
select
if(max(period) < date_format(date_sub(now(), interval :ago month),'%Y%m'),
date_format(now(),'%Y%m'),
greatest(min(period), date_format(date_sub(now(), interval :ago month),'%Y%m')))
from ProjectCommitActivity
where project=':id')
and date_format(now(),'%Y%m')) as periods
left join
ProjectCommitActivity as commits
on (periods.period = commits.period and commits.project=':id')
order by period
")
->substitute(':id', $project->getId())
->substitute(':ago', $age)
->column('Month', 'period', 'string', function($value) {return asYearMonth($value);})
->column('Commits', 'count', 'number')
->columnChart()
->height(300)
->width(640)
->option('legend', 'none')
->render();
echo "</div>";
}
});
}
?>
</div>
<div id="rightcolumn">
<div class="sideitem">
<h6>Top LeveL Projects</h6>
<?php selectTopLevelProject(); ?>
</div>
</div>
</div>
<?php
$html = ob_get_contents ();
ob_end_clean ();
$App->generatePage ( $theme, $Menu, $Nav, $pageAuthor, $pageKeywords, $pageTitle, $html );
?>