blob: 3b461557519d8a4db443505835138b16b8a55dcd [file] [log] [blame]
<?php
/**
* *****************************************************************************
* Copyright (c) 2016,2017 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 dirname ( __FILE__ ) . '/charts.inc';
require_once dirname ( __FILE__ ) . '/../classes/database.inc';
// function renderMonthlyTop10Chart() {
// global $App;
// $period = date ( 'Ym', strtotime ( '-1 month' ) );
// $sql = "
// select project, count
// from SubprojectCommitActivity
// where period='$period'
// order by count desc
// limit 10;";
// $rows = array ();
// query ( 'dashboard', $sql, array (), function ($row) use (&$rows) {
// $id = $row ['project'];
// $project = get_project_from_pmi ( $id );
// $name = $project ? $project->getName () : $id;
// $count = $row ['count'];
// $rows [] = array (
// $name,
// $count
// );
// } );
// $period = asYearMonth ( $period );
// echo "<p>The determination of &quot;Top 10&quot; is based on commits made
// against the project in $period.</p>";
// $columns = array (
// array (
// 'label' => 'Project',
// 'type' => 'string'
// ),
// array (
// 'label' => 'Commits',
// 'type' => 'number'
// )
// );
// drawPieChart ( 'Top10Monthly', "Top Ten Projects by Contributor Count ($period)", $columns, $rows );
// }
function renderIPTeamVelocityChart($age = 5) {
global $App;
$start = date ( 'Y-m-01', strtotime ( "- $age years" ) );
$end = date ( 'Y-m-t', strtotime ( "- 1 month" ) );
$sql = "
select
date_format(ba.bug_when, '%Y-%m') as period,
count(distinct c.id) as projects,
count(distinct date(ba.bug_when)) as days,
count(distinct ba.bug_id) as bugs
from bugs_activity as ba
join bugs as b on ba.bug_id=b.bug_id
join components as c on b.component_id=c.id
where
added='RESOLVED'
and ba.bug_when between date('$start') and date('$end')
and b.short_desc not regexp '\((PB( Orbit)?)\s*\d*\)'
and b.short_desc not regexp '\(ATO\s*\d*\)'
and b.cf_type not in ('Type_A')
and c.name not in ('IP_Discussion')
group by date_format(ba.bug_when, '%Y-%m')
";
$rows = array ();
query ( 'ipzilla', $sql, array (), function ($row) use (&$rows) {
$period = $row ['period'];
$projects = $row ['projects'];
$days = $row ['days'];
$bugs = $row ['bugs'];
$period = asYearMonth ( $period );
$rows [] = array (
$period,
$bugs / $days
);
} );
$start = asYearMonth ( $start );
$end = asYearMonth ( $end );
echo "<p>Based on CQ state between $start and $end.</p>";
$columns = array (
array (
'label' => 'Month',
'type' => 'string'
),
array (
'label' => 'CQs Resolved/Day',
'type' => 'number'
)
);
$options = array (
'curveType' => 'function',
'vAxis' => array (
'viewWindowMode' => 'explicit',
'viewWindow' => array (
'min' => 0
)
)
);
drawLineChart ( 'IPTeamVelocity', "Average IP Team Velocity Between $start and $end", $columns, $rows, $options );
}
function renderByProjectIPChart() {
global $App;
$now = date ( 'Y-m' );
$last = date ( 'Y-m', strtotime ( "-1 months" ) );
$sql = "
SELECT
CMP.name as project,
count(BUG.bug_id) as count
FROM (SELECT DISTINCT date_format(creation_ts, \"%Y-%m\") AS Month FROM bugs) AS DAT
INNER JOIN bugs as BUG ON date_format(BUG.creation_ts, \"%Y-%m\") <= Month
INNER JOIN products AS PRD ON PRD.id = BUG.product_id
INNER JOIN components AS CMP ON CMP.id = BUG.component_id
LEFT JOIN bugs_activity AS ACT on ACT.bug_id = BUG.bug_id
AND ACT.added = \"RESOLVED\"
WHERE BUG.resolution != \"INVALID\"
AND PRD.name != \"IP\"
AND BUG.keywords not like '%historical%'
AND CMP.name != \"tools.orbit\"
AND (ACT.bug_when IS NULL OR date_format(ACT.bug_when,\"%Y-%m\") > Month)
AND DAT.Month >= \"$last\"
AND DAT.Month < \"$now\"
GROUP BY CMP.name
ORDER BY count desc
LIMIT 15";
$rows = array ();
query ( 'ipzilla', $sql, array (), function ($row) use (&$rows) {
$project = Project::getProject ( $row ['project'] );
$rows [] = array (
$project == null ? $row ['project'] : $project->getNickName (),
$row ['count']
);
} );
$date = date ( 'M Y' );
$columns = array (
array (
'label' => 'Project',
'type' => 'string'
),
array (
'label' => 'CQs',
'type' => 'number'
)
);
drawPieChart ( 'ProjectCQs', "CQ Breakdown by Project (Top 15) $date", $columns, $rows );
}
/*
* select date, name as project, count(bug_id) from (select
* date_format(ba.bug_when, "%Y-%m") as date, b.bug_id, p.name, b.short_desc
* from bugs_activity as ba join bugs as b on ba.bug_id=b.bug_id join products
* as p on b.product_id=p.id where ba.added='RESOLVED' and p.name not in ('IP'))
* as cqs group by date, project;
*/
function renderQuarterlyTop10Chart() {
global $App;
list ( $quarter, $start, $end ) = getLastQuarter ( time () );
$sql = "
select project, count
from SubprojectCommitActivity
where period between $start and $end
group by project
order by count desc";
$rows = array ();
query ( 'dashboard', $sql, array (), function ($row) use (&$rows) {
$project = Project::getProject ( $row ['project'] );
$count = $row ['count'];
$rows [] = array (
$project ? $project->getNickName () : $row['project'],
$count
);
} );
echo "<p>Based on commits between $start and $end.</p>";
$columns = array (
array (
'label' => 'Project',
'type' => 'string'
),
array (
'label' => 'CQs',
'type' => 'number'
)
);
drawPieChart ( 'Top10Quarterly', "Top Ten Projects by Contribution Count ($quarter)", $columns, $rows );
}
function renderQuarterlyTop10ContributorsChart() {
global $App;
list ( $quarter, $start, $end ) = getLastQuarter ( time () );
$sql = "
select
project, Authors-Committers as count
from ProjectQuarterlySummary
where quarter='$quarter'
and Authors-Committers >= (
select Authors-Committers as count
from ProjectQuarterlySummary
where quarter='$quarter'
order by count desc limit 10, 1)
order by count desc";
$rows = array ();
query ( 'dashboard', $sql, array (), function ($row) use (&$rows) {
$project = Project::getProject ( $row ['project'] );
$count = $row ['count'];
$rows [] = array (
$project ? $project->getNickName () : $row['project'],
$count
);
} );
echo "<p>Based on commits between $start and $end.</p>";
$columns = array (
array (
'label' => 'Project',
'type' => 'string'
),
array (
'label' => 'Commits',
'type' => 'number'
)
);
drawPieChart ( 'Top10ContributorsQuarterly', "Top \"Ten\" Projects by Contributor Count ($quarter)", $columns, $rows );
}
function renderFileTypesChart() {
global $App;
list ( $quarter, $start, $end ) = getLastQuarter ( time () );
$sql = "select extension, count from FileTypes order by count desc limit 15";
$rows = array ();
query ( 'dashboard', $sql, array (), function ($row) use (&$rows) {
$id = $row ['extension'];
$name = getExtensionName ( $id );
$count = $row ['count'];
$rows [] = array (
$name,
$count
);
} );
$columns = array (
array (
'label' => 'File Type',
'type' => 'string'
),
array (
'label' => 'Number of projects',
'type' => 'number'
)
);
drawPieChart ( 'fileTypesChart', "File types by project use", $columns, $rows );
}
function renderLicensesInUseChart() {
global $App;
$now = date ( 'Y-m' );
$sql = "
SELECT
license, count(project) as count
from (
SELECT
p.ProjectId as project,
group_concat(
if(LicenseId='EPL1.0','EPL-1.0',
if(LicenseId='EPL2.0','EPL-2.0',
if(LicenseId='EDL1.0','EDL-1.0',
if(LicenseId='ASL2.0','Apache-2.0',
if(LicenseId='CCBY3','CC-BY-3.0',
LicenseId)))))
ORDER BY LicenseId separator ' OR ') as license
FROM ProjectLicenses as pl
JOIN Projects as p on pl.ProjectId=p.ProjectId
AND p.IsActive group by p.ProjectId
) as ProjectsAndLicenses
group by license
order by count desc";
$rows = array ();
query ( 'foundation', $sql, array (), function ($row) use (&$rows) {
$rows [] = array (
$row ['license'],
$row ['count']
);
} );
$columns = array (
array (
'label' => 'License',
'type' => 'string'
),
array (
'label' => 'Count',
'type' => 'number'
)
);
drawPieChart ( 'LicenseUse', "Licenses in use by Eclipse Projects on $now", $columns, $rows );
}
?>