blob: b2236e43ee05692c6ece7544289a96348f587841 [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';
function getActivityChartData($age = 5) {
global $App;
/*
* Only query the last five years worth of data. Exclude
* the current month.
*/
$start = date('Ym', strtotime("- $age years"));
$end = date('Ym');
$sql = "
select
period,
projects, activeProjects, commits,
activeAuthors,
committers, monthlyCommitters, participatingCommitters, activeCommitters, activeCompanies
from MonthlySummary
where period >= $start and period < $end";
$result = $App->dashboard_sql($sql);
$contributors = array();
$committers = array();
$projects = array();
while ($row = mysql_fetch_assoc($result)) {
if (!preg_match('/(\d\d\d\d)(\d\d)/',$row['period'], $matches)) continue;
$date = strtotime($matches[1] . '-' . $matches[2] . '-01');
$period = date('M Y', $date);
$projectsCount = (int)$row['projects'];
$activeProjects = (int)$row['activeProjects'];
$contributorsCount = (int)$row['activeAuthors'] - (int)$row['monthlyCommitters'];
$committersCount = (int)$row['committers'];
$activeCommitters = (int)$row['activeCommitters'];
$participatingCommitters = (int)$row['participatingCommitters'];
$companies = (int)$row['activeCompanies'];
$contributors[] = array($period, $contributorsCount);
$committers[] = array($period, $committersCount, $activeCommitters, $participatingCommitters);
$projects[] = array($period, $projectsCount, $activeProjects, $companies);
}
return array(json_encode($contributors), json_encode($committers), json_encode($projects));
}
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;";
$result = $App->dashboard_sql($sql);
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$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 renderMonthlyCommitsChart($age = 5) {
global $App;
$start = date('Ym', strtotime("- $age years"));
$end = date('Ym');
$sql = "
select
period, commits as count
from MonthlySummary
where period >= $start and period < $end";
$result = $App->dashboard_sql($sql);
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$period = $row['period'];
$count = $row['count'];
if (!preg_match('/(\d\d\d\d)(\d\d)/',$row['period'], $matches)) continue;
$date = strtotime($matches[1] . '-' . $matches[2] . '-01');
$period = date('M Y', $date);
$rows[] = array($period, $count);
}
$start = asYearMonth($start);
$end = asYearMonth($end);
echo "<p>Based on commits between $start and $end.</p>";
$columns = array(
array('label' => 'Project', 'type' => 'string'),
array('label' => 'Commits', 'type' => 'number')
);
$options = array(
'curveType' => 'function',
);
drawLineChart('MonthlyCommits', "Commits by Month ($start to $end)", $columns, $rows, $options);
}
function renderMonthlyCqsChart($age = 5) {
global $App;
$start = date('Y-m', strtotime("- $age years"));
$end = date('Y-m');
$sql = "
SELECT Month, bug_count
FROM _ipzilla_historical
WHERE Month >= \"$start\"
UNION
SELECT DAT.Month, count(*) as bug_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
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 (ACT.bug_when IS NULL OR date_format(ACT.bug_when,\"%Y-%m\") > Month)
AND DAT.Month >= \"$start\"
And DAT.Month < \"$end\"
GROUP BY Month";
$result = $App->ipzilla_sql($sql);
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$period = $row['Month'];
$count = $row['bug_count'];
$period = asYearMonth($period);
$rows[] = array($period, $count);
}
$start = asYearMonth($start);
$end = asYearMonth($end);
echo "<p>Based on CQ state between $start and $end.</p>";
$columns = array(
array('label' => 'Project', 'type' => 'string'),
array('label' => 'Commits', 'type' => 'number')
);
$options = array(
'curveType' => 'function',
);
drawLineChart('MonthlyCqs', "Open CQs Over Time ($start to $end)",$columns, $rows, $options);
}
function renderMonthlyCqsTypeChart($age = 5) {
global $App;
$start = date('Y-m', strtotime("- $age years"));
$end = date('Y-m',strtotime("- 1 month"));
$sql = "
select
date,
sum(if(type='projectcode',1,0)) as projectcode,
sum(if(type='piggyback',1,0)) as piggyback,
sum(if(type='thirdparty',1,0)) as thirdparty,
sum(if(type='orbit',1,0)) as orbit,
sum(if(type='iplog',1,0)) as iplog
from
(select
date_format(b.creation_ts, '%Y-%m') as date,
b.bug_id,
if(b.short_desc regexp '\\(PB( ORBIT)? CQ[[:digit:]]+\\)', 'piggyback',
if(b.short_desc regexp '\\(ATO CQ[[:digit:]]+\\)', 'orbit',
kwd.name)) as type,
b.short_desc
from bugs as b
join keywords as kw on b.bug_id=kw.bug_id
join keyworddefs as kwd on kw.keywordid=kwd.id
and kwd.name in ('iplog', 'thirdparty', 'projectcode')
) as cqs
where date between '$start' and '$end'
group by date";
$result = $App->ipzilla_sql($sql);
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$period = $row['date'];
$projectcode = $row['projectcode'];
$piggyback = $row['piggyback'];
$thirdparty = $row['thirdparty'];
$orbit = $row['orbit'];
$iplog = $row['iplog'];
$period = asYearMonth($period);
$rows[] = array($period, $projectcode, $piggyback, $thirdparty, $orbit, $iplog);
}
$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' => 'Project Code CQs', 'type' => 'number'),
array('label' => 'Piggyback CQs', 'type' => 'number'),
array('label' => 'Third Party CQs', 'type' => 'number'),
array('label' => 'Add to Orbit', 'type' => 'number'),
array('label' => 'IP Log Approvals', 'type' => 'number')
);
$options = array(
'curveType' => 'function',
);
drawLineChart('CqTypes', "CQs by Type Created Between $start and $end", $columns, $rows, $options);
}
function renderMonthlyThirdPartyCqTypeChart($age = 5) {
global $App;
$start = date('Y-m', strtotime("- $age years"));
$end = date('Y-m',strtotime("- 1 month"));
$sql = "
select
date_format(creation_ts, '%Y-%m'),
sum(if(cf_type='Type_A',1,0)) as typeA,
sum(if(cf_type='Type_B',1,0)) as typeB
from bugs as b
join keywords as kw on b.bug_id=kw.bug_id
join keyworddefs as kd on kw.keywordid=kd.id
where kd.name='thirdparty'
and date_format(creation_ts, '%Y-%m') between '$start' and '$end'
group by date_format(creation_ts, '%Y%m')";
$result = $App->ipzilla_sql($sql);
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$period = $row['date'];
$period = asYearMonth($period);
$rows[] = array($period, $row['typeA'], $row['typeB']);
}
$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' => 'Type A', 'type' => 'number'),
array('label' => 'Type B', 'type' => 'number')
);
$options = array(
'curveType' => 'function',
'vAxis' => array(
'viewWindowMode' => 'explicit',
'viewWindow' => array('min' => 0)
)
);
drawLineChart('ThirdPartyCqTypes', "Third Party CQs by Type Created Between $start and $end", $columns, $rows, $options);
}
function renderMonthlyCqsResolutionChart($age = 5) {
global $App;
$start = date('Y-m', strtotime("- $age years"));
$end = date('Y-m',strtotime("- 1 month"));
$sql = "
select
date,
sum(if(type='projectcode',1,0)) as projectcode,
sum(if(type='piggyback',1,0)) as piggyback,
sum(if(type='thirdparty',1,0)) as thirdparty,
sum(if(type='orbit',1,0)) as orbit,
sum(if(type='iplog',1,0)) as iplog
from
(select
date_format(ba.bug_when, \"%Y-%m\") as date,
b.bug_id,
if(b.short_desc regexp '\\(PB( ORBIT)? CQ[[:digit:]]+\\)', 'piggyback',
if(b.short_desc regexp '\\(ATO CQ[[:digit:]]+\\)', 'orbit',
kwd.name)) as type,
b.short_desc
from bugs_activity as ba
join bugs as b on ba.bug_id=b.bug_id
join keywords as kw on b.bug_id=kw.bug_id
join keyworddefs as kwd on kw.keywordid=kwd.id
and kwd.name in ('iplog', 'thirdparty', 'projectcode')
where ba.added='RESOLVED') as cqs
where date between '$start' and '$end'
group by date";
$result = $App->ipzilla_sql($sql);
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$period = $row['date'];
$projectcode = $row['projectcode'];
$piggyback = $row['piggyback'];
$thirdparty = $row['thirdparty'];
$orbit = $row['orbit'];
$iplog = $row['iplog'];
$period = asYearMonth($period);
$rows[] = array($period, $projectcode, $piggyback, $thirdparty, $orbit, $iplog);
}
$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' => 'Project Code CQs', 'type' => 'number'),
array('label' => 'Piggyback CQs', 'type' => 'number'),
array('label' => 'Third Party CQs', 'type' => 'number'),
array('label' => 'Add to Orbit', 'type' => 'number'),
array('label' => 'IP Log Approvals', 'type' => 'number')
);
$options = array(
'curveType' => 'function',
);
drawLineChart('ResolvedCqs', "Resolved CQs by Type Between $start and $end", $columns, $rows, $options);
}
function renderByTopLevelProjectIPChart() {
global $App;
$now = date('Y-m');
$last = date('Y-m', strtotime("-1 months"));
$sql = "
SELECT
PRD.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 PRD.name
ORDER BY count desc";
$result = $App->ipzilla_sql($sql);
$products = array();
while ($row = mysql_fetch_assoc($result)) {
$name = getProjectNickName($row['project']);
$rows[] = array($name, $row['count']);
}
$date = date('M Y');
$columns = array(
array('label' => 'Project', 'type' => 'string'),
array('label' => 'CQs', 'type' => 'number'),
);
drawPieChart('TLPCQs', "CQ Breakdown by Top-Level Project (Top 15) $date", $columns, $rows);
}
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";
$result = $App->ipzilla_sql($sql);
$products = array();
while ($row = mysql_fetch_assoc($result)) {
$name = getProjectNickName($row['project']);
$rows[] = array($name, $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
limit 10;";
$result = $App->dashboard_sql($sql);
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$id = $row['project'];
$name = getProjectNickName($id);
$count = $row['count'];
$rows[] = array($name, $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";
$result = $App->dashboard_sql($sql);
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$id = $row['project'];
$name = getProjectNickName($id);
$count = $row['count'];
$rows[] = array($name, $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";
$result = $App->dashboard_sql($sql);
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$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);
}
?>