[git] web/qa.git branch master updated. 086d57c

From: Date: Wed, 15 Feb 2012 01:07:47 +0000
Subject: [git] web/qa.git branch master updated. 086d57c
Groups: php.qa 
Request: Send a blank email to php-qa+get-66098@lists.php.net to get a copy of this message
The branch, master on web/qa.git has been updated via 086d57c5c51bc9820b009782ac7e860250051cdf (commit) from 8a232b9c47be008c1609f9fa008d53706c79a246 (commit) http://git.php.net/?p=web/qa.git;a=log;h=086d57c5c51bc9820b009782ac7e860250051cdf;hp=8a232b9c47be008c1609f9fa008d53706c79a246 Summary of changes: reports/index.php | 6 ++- reports/reportsfunctions.php | 121 ++++++++++++++++++++++++++++++++---------- 2 files changed, 98 insertions(+), 29 deletions(-) -- Log ---------------------------------------- commit 086d57c5c51bc9820b009782ac7e860250051cdf Author: Johannes Schlüter <johannes@php.net> Date: Wed Feb 15 01:59:25 2012 +0100 Filter out old RC and -dev versions. This can be overriden using a URL parameter, which is not yet exported as link to the UI. diff --git a/reports/index.php b/reports/index.php index 2ed82ef..ff4bf45 100644 --- a/reports/index.php +++ b/reports/index.php @@ -60,7 +60,11 @@ if (isset($_GET['version'])) { $database->close(); } else { - + if (!isset($_GET['summary_filter'])) { + $filter = QA_REPORT_FILTER_ALL; + } else { + $filter = $_GET['summary_filter']; + } $reportsPerVersion = get_summary_data(); $TITLE = "PHP Test Reports Summary"; diff --git a/reports/reportsfunctions.php b/reports/reportsfunctions.php index 8cdb7d2..df211fc 100644 --- a/reports/reportsfunctions.php +++ b/reports/reportsfunctions.php @@ -13,45 +13,110 @@ # | license@php.net so we can mail you a copy immediately. | # +----------------------------------------------------------------------+ # | Author: Olivier Doucet <odoucet@php.net> | +# | Johannes Schlüter <johannes@php.net> | # +----------------------------------------------------------------------+ # $Id$ +class QaReportIterator extends FilterIterator +{ + public function __construct(DirectoryIterator $inner) + { + parent::__construct($inner); + } + + public function accept() + { + return substr(parent::current(), -7) == '.sqlite'; + } + + public function key() + { + return substr(parent::current(), 0, -7); + } + + public function current() + { + return __DIR__.'/db/'.parent::current()." for ".$this->key()."\n"; + } +} + +abstract class WhitelistedFilterIterator extends FilterIterator +{ + private $whitelist; + + public function __construct(Traversable $inner, array $whitelist) + { + parent::__construct($inner); + $this->whitelist = $whitelist; + } + + public function inWhitelist() + { + return in_array($this->key(), $this->whitelist); + } +} + +class RCFilterIterator extends WhitelistedFilterIterator +{ + public function accept() + { + return $this->inWhitelist() || !preg_match(',RC[0-9]+$,', $this->key()); + } +} + +class devFilterIterator extends WhitelistedFilterIterator +{ + public function accept() + { + return $this->inWhitelist() || substr($this->key(), -4) != '-dev'; + } +} + +const QA_REPORT_FILTER_NONE = 0; +const QA_REPORT_FILTER_RC = 1; +const QA_REPORT_FILTER_DEV = 2; + +const QA_REPORT_FILTER_ALL = 3; + /** * Analyse sqlite files and retrieve data from it * @return array */ -function get_summary_data() +function get_summary_data($mode = QA_REPORT_FILTER_ALL) { + global $QA_RELEASES; + $data = array(); - $d = dir(dirname(__FILE__).'/db/'); - while (false !== ($entry = $d->read())) { - if (substr($entry, -7) == '.sqlite') { - //extract version from filename - $version = substr($entry, 0, -7); - - // open database file - $database = new SQLite3(dirname(__FILE__).'/db/'.$entry, SQLITE3_OPEN_READONLY); - - //retrieve data - $query = $database->query( - "SELECT COUNT(*) AS nbReports, MAX(date) AS lastReport FROM reports" - ); - if (!$query) - die("An error occured when reading a DB file."); - $row = $query->fetchArray(SQLITE3_ASSOC); - $data[$version] = $row; + $it = new QaReportIterator(new DirectoryIterator(__DIR__.'/db/')); + + if ($mode & QA_REPORT_FILTER_RC) { + $it = new RCFilterIterator($it, $QA_RELEASES['reported']); + } + if ($mode & QA_REPORT_FILTER_DEV) { + $it = new devFilterIterator($it, $QA_RELEASES['reported']); + } + + foreach ($it as $version => $database_file) { + $database = new SQLite3($database_file, SQLITE3_OPEN_READONLY); + //retrieve data + $query = $database->query( + "SELECT COUNT(*) AS nbReports, MAX(date) AS lastReport FROM reports" + ); + if (!$query) + die("An error occured when reading a DB file."); + $row = $query->fetchArray(SQLITE3_ASSOC); + $data[$version] = $row; - $query = $database->query( - "select count(distinct test_name) as nbFailingTests, count(*) as nbFailures from failed" - ); - if (!$query) - die("An error occured when reading a DB file."); - $row = $query->fetchArray(SQLITE3_ASSOC); - $data[$version]['nbFailingTests'] = $row['nbFailingTests']; - $data[$version]['nbFailures'] = $row['nbFailures']; + $query = $database->query( + "select count(distinct test_name) as nbFailingTests, count(*) as nbFailures from failed" + ); + if (!$query) + die("An error occured when reading a DB file."); + $row = $query->fetchArray(SQLITE3_ASSOC); + $data[$version]['nbFailingTests'] = $row['nbFailingTests']; + $data[$version]['nbFailures'] = $row['nbFailures']; - $database->close(); - } + $database->close(); } return $data; } Thank you for your contribution.

« previous php.qa (#66098) next »