blob: 702852b8af1345b9276456f3a4c9bff9224d85ad [file] [log] [blame]
<?php
/**
* THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (http://www.eclipse.org/legal/epl-v10.html).
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
*
*/
/**
*
*/
require_once("/home/data/httpd/eclipse-php-classes/system/dbconnection_dashboard_rw.class.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/dashboard/utils.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/stats/hostname.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/stats/common_queries.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/dashboard/constants.php");
/**
* Dashboard Project Statistics
*
* This Class provides an interface to the Project Dashboard. the Dashboard is designed to provide you with a sense of how well
* your project is functioning. Is it making progress? Falling behind? Does it have an active community? And so on
*
* @license http://www.eclipse.org/legal/epl-v10.html Eclipse Public License - v 1.0
*
* @author Eduardo A. Romero Gomez
*
*
*/
class DashboardInfo {
var $project_id = "";
var $liveness = 0;
var $bugs = 0;
var $delta7 = 0;
var $delta30 = 0;
var $delta180 = 0;
var $perc7 = 0;
var $perc30 = 0;
var $perc180 = 0;
var $news7 = 0;
var $news30 = 0;
var $answers7 = 0;
var $answers30= 0;
var $dashboard_week = "";
/**
* Constructor, it takes the Project Key (as in the Foundation Database) as a parameter
*
* Create a new DashboardInfo object.
* The DashboardInfo object provides an easy to use interface to the Project Dashboard.
*
* @param string $projectkey the project's key as in the Eclipse Foundation's database
* of projects. These keys are assigned by the EMO.
*
* @param string date you can pass a week in MySQL date format (yyyy-mm-dd) to fetch
* results for the week starting on that date.
* If no $_week is given current calculations are used.
*
* @return DashboardInfo A brand new DashboardInfo object
*
*/
function DashboardInfo($_project_id, $_date = "")
{
$this->project_id = $_project_id;
$dbc_cache = new DBConnectionDashboard();
$db_handle = $dbc_cache->connect();
$this->dashboard_week = $_date;
if($_date == "")
$mysql_date = get_last_date($db_handle);
else
$mysql_date = $_date;
$query = "SELECT * FROM ".stats_table()." WHERE stats_date = \"".$mysql_date."\" AND project_id = \"".$this->project_id."\"";
$result = mysql_query($query,$db_handle) or die("MySQL Error: ".mysql_error());
$row = mysql_fetch_assoc($result);
$this->liveness = $row['liveness'];
$this->bugs = $row['bugs_total'];
$this->delta7 = $row['bugs_7_delta'];
$this->delta30 = $row['bugs_30_delta'];
$this->delta180 = $row['bugs_180_delta'];
$this->perc7 = $row['bugs_7_percentage'];
$this->perc30 = $row['bugs_30_percentage'];
$this->perc180 = $row['bugs_180_percentage'];
$this->news7 = $row['news_7_number_posts'];
$this->news30 = $row['news_30_number_posts'];
$this->answers7 = $row['news_7_answer_average_time'];
$this->answers30= $row['news_30_answer_average_time'];
}
/**
* Returns the Liveness of a project
*
* Returns the liveness of the project, according to the Project Dashboards calculations formula:
* <pre>
* 1 * log(last week change in number of bugs) +
* 1 * log(last week bug fix rate percentage) +
* 2 * log(last month bug fix rate percentage) +
* 1 * log(180 day bug fix rate percentage) +
* 2 * log(last week number of newsgroup postings) +
* 2 * 1/(last week newsgroup answers times) +
* 3 * log(last month number of newsgroup postings) +
* 3 * 1/(last month newsgroup answers times).
* </pre>
* Optionally you can pass a week in MySQL date format (yyyy-mm-dd) to fetch
* results for the week starting on that date. If no $_week is given current calculations are used.
*
* @access public
*/
function getLiveness()
{
return $this->liveness;
}
/**
* Returns the number of bugs this project has
*
*
* The number of bugs this project has in the Eclipse Bugzilla bug tracking system
*
* Optionally you can pass a week in MySQL date format (yyyy-mm-dd) to fetch
* results for the week starting on that date. If no $_week is given current calculations are used.
*
* @link http://bugs.eclipse.org
* @access public
*/
function getBugs()
{
return $this->bugs;
}
/**
*
* How the number number of bugs this project has changed in the past week
*
* Optionally you can pass a week in MySQL date format (yyyy-mm-dd) to fetch
* results for the week starting on that date. If no $_week is given current calculations are used.
*
* @link http://www.eclipse.org/projects/dashboard/descriptions.php
* @access public
*/
function getBugs7Delta()
{
return $this->delta7;
}
/**
*
* How the number number of bugs this project has changed in the past month
*
* Optionally you can pass a week in MySQL date format (yyyy-mm-dd) to fetch
* results for the week starting on that date. If no $_week is given current calculations are used.
*
* @link http://www.eclipse.org/projects/dashboard/descriptions.php
* @access public
*/
function getBugs30Delta()
{
return $this->delta30;
}
/**
*
* How the number number of bugs this project has changed in the past 180 days
*
* Optionally you can pass a week in MySQL date format (yyyy-mm-dd) to fetch
* results for the week starting on that date. If no $_week is given current calculations are used.
*
* @link http://www.eclipse.org/projects/dashboard/descriptions.php
* @access public
*/
function getBugs180Delta()
{
return $this->delta180;
}
/**
* Past 7 days Bug fix rate
*
* The difference in the number of closed (resolved, closed, and verified) bugs and
* enhancements to the number of open and active (P1, P2, P3) bugs for the <i>last week</i>.
* The goal is to keep the number positive because then the project is fixing bugs and
* implementing features faster than bugs are being reported.
*
* Optionally you can pass a week in MySQL date format (yyyy-mm-dd) to fetch
* results for the week starting on that date. If no $_week is given current calculations are used.
*
* @link http://www.eclipse.org/projects/dashboard/descriptions.php
* @access public
*/
function getBugs7Percentage()
{
return $this->perc7;
}
/**
* Past 30 dyas Bug fix rate
*
* The difference in the number of closed (resolved, closed, and verified) bugs and
* enhancements to the number of open and active (P1, P2, P3) bugs for the <i>last month</i>.
* The goal is to keep the number positive because then the project is fixing bugs and
* implementing features faster than bugs are being reported.
*
* Optionally you can pass a week in MySQL date format (yyyy-mm-dd) to fetch
* results for the week starting on that date. If no $_week is given current calculations are used.
*
* @link http://www.eclipse.org/projects/dashboard/descriptions.php
* @access public
*/
function getBugs30Percentage()
{
return $this->perc30;
}
/**
* Past 180 days Bug fix rate
*
* The difference in the number of closed (resolved, closed, and verified) bugs and
* enhancements to the number of open and active (P1, P2, P3) bugs for the past<i>180 days</i>.
* The goal is to keep the number positive because then the project is fixing bugs and
* implementing features faster than bugs are being reported.
*
* Optionally you can pass a week in MySQL date format (yyyy-mm-dd) to fetch
* results for the week starting on that date. If no $_week is given current calculations are used.
*
* @link http://www.eclipse.org/projects/dashboard/descriptions.php
* @access public
*/
function getBugs180Percentage()
{
return $this->perc180;
}
/**
* Number of posts in the past 7 days
*
* Total number of posts made in the last 7 days. The number of posts will be -1 when the
* newsgroup for a project does not exist and it is not possible to compute the statistics.
* When the group for the project exists but it is currently empty (no posts) or there are
* no posts for the last 7 days then it will be 0.
*
* Optionally you can pass a week in MySQL date format (yyyy-mm-dd) to fetch
* results for the week starting on that date. If no $_week is given current calculations are used.
*
* @link http://www.eclipse.org/projects/dashboard/descriptions.php
* @access public
*/
function getNews7NumberPosts()
{
return $this->news7;
}
/**
* Number of posts in the past 30 days
*
* Total number of posts made in the last 30 days. The number of posts will be -1 when the
* newsgroup for a project does not exist and it is not possible to compute the statistics.
* When the group for the project exists but it is currently empty (no posts) or there are
* no posts for the last 30 days then it will be 0.
*
* Optionally you can pass a week in MySQL date format (yyyy-mm-dd) to fetch
* results for the week starting on that date. If no $_week is given current calculations are used.
*
* @link http://www.eclipse.org/projects/dashboard/descriptions.php
* @access public
*/
function getNews30NumberPosts()
{
return $this->news30;
}
/**
* Average time to response a post (past 7 days)
*
* Average time it takes for a post that was answered to be answered in the last 7 days.
* The Time To Reply (TTR) is computed as the difference between the time of the original
* post and the time of the reply using the NNTP-Posting-Date. If there were no answers for
* the specified period then the it will be 0. If the newsgroup does
* not exist then it will be -1.
*
* Optionally you can pass a week in MySQL date format (yyyy-mm-dd) to fetch
* results for the week starting on that date. If no $_week is given current calculations are used.
*
* @link http://www.eclipse.org/projects/dashboard/descriptions.php
* @access public
*/
function getNews7AnswerAverageTime()
{
return $this->answers7;
}
/**
* Average time to response a post (past 30 days)
*
* Average time it takes for a post that was answered to be answered in the last 30 days.
* The Time To Reply (TTR) is computed as the difference between the time of the original
* post and the time of the reply using the NNTP-Posting-Date. If there were no answers for
* the specified period then the it will be 0. If the newsgroup does
* not exist then it will be -1.
*
* Optionally you can pass a week in MySQL date format (yyyy-mm-dd) to fetch
* results for the week starting on that date. If no $_week is given current calculations are used.
*
* @link http://www.eclipse.org/projects/dashboard/descriptions.php
* @access public
*/
function getNews30AnswerAverageTime()
{
return $this->answers30;
}
/**
* HTML dashboard-like Bug Lights
* <pre>
*
* There's 3 lights they represent last week, last month and last 180 days:
*
* <7> <30> <180>
*
* Light
* white light Regular
* green light Good
* red light Bad
* </pre>
*
* Optionally you can pass a week in MySQL date format (yyyy-mm-dd) to fetch
* results for the week starting on that date. If no $_week is given current calculations are used.
*
* @access public
* @link http://www.eclipse.org/projects/dashboard/descriptions.php The Dashboard
* @example examples/dashboard_lights.php A simple example
*
*/
function PrintBugsLights()
{
echo "<a href=\"/projects/dashboard/dashboard_detail.php?project=$this->project_id\">".light_bugs($this->bugs, $this->delta7, $this->perc7);
echo light_bugs($this->bugs, $this->delta30, $this->perc30);
echo light_bugs($this->bugs, $this->delta180, $this->perc180)."</a>\n";
}
/**
* HTML dashboard-like News Lights
* <pre>
*
* There's 4 lights they represent number of posts and average response time to a post
* for the last 7 and 30 days:
*
* <#posts_7> <#posts_30> <#avg_ttr_7> <#avg_ttr_30>
*
* Light
* white light Regular
* green light Good
* red light Bad
* </pre>
*
* Optionally you can pass a week in MySQL date format (yyyy-mm-dd) to fetch
* results for the week starting on that date. If no $_week is given current calculations are used.
*
* @access public
* @example examples/dashboard_lights.php "A simple example"
* @link http://www.eclipse.org/projects/dashboard/descriptions.php The Dashboard
*/
function PrintNewsLights()
{
echo "<a href=\"/projects/dashboard/dashboard_detail.php?project=$this->project_id\">".
light_news($this->news7, POSTS_7_RED, POSTS_7_GREEN);
echo light_news_answers($this->answers7, $this->news7);
echo light_news($this->news30, POSTS_30_RED, POSTS_30_GREEN);
echo light_news_answers($this->answers30, $this->news30)."</a>\n";
}
}
?>