cvs: php-gcov-web /cron cron.php graph.php /www viewer.php

From: Date: Tue, 19 Dec 2006 18:42:06 +0000
Subject: cvs: php-gcov-web /cron cron.php graph.php /www viewer.php
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-33558@lists.php.net to get a copy of this message
nlopess Tue Dec 19 18:42:06 2006 UTC Modified files: /php-gcov-web/cron cron.php graph.php /php-gcov-web/www viewer.php Log: add yearly graphs

http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/cron.php?r1=1.3&r2=1.4&diff_format=u Index: php-gcov-web/cron/cron.php diff -u php-gcov-web/cron/cron.php:1.3 php-gcov-web/cron/cron.php:1.4 --- php-gcov-web/cron/cron.php:1.3 Tue Dec 19 16:45:07 2006 +++ php-gcov-web/cron/cron.php Tue Dec 19 18:42:06 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: cron.php,v 1.3 2006/12/19 16:45:07 nlopess Exp $ */ +/* $Id: cron.php,v 1.4 2006/12/19 18:42:06 nlopess Exp $ */ if ($argc != 7) @@ -153,11 +153,7 @@ // Graphs will be generated and the database updated with the latest build information if($makestatus == 'pass') - { - $graph_mode = 'weekly'; - require $workdir.'/graph.php'; - - $graph_mode = 'monthly'; + { require $workdir.'/graph.php'; // Do SQL updates for the specific PHP version http://cvs.php.net/viewvc.cgi/php-gcov-web/cron/graph.php?r1=1.3&r2=1.4&diff_format=u Index: php-gcov-web/cron/graph.php diff -u php-gcov-web/cron/graph.php:1.3 php-gcov-web/cron/graph.php:1.4 --- php-gcov-web/cron/graph.php:1.3 Tue Dec 19 16:45:07 2006 +++ php-gcov-web/cron/graph.php Tue Dec 19 18:42:06 2006 @@ -14,10 +14,11 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Daniel Pronych <pronych@php.net> | + | Nuno Lopes <nlopess@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: graph.php,v 1.3 2006/12/19 16:45:07 nlopess Exp $ */ +/* $Id: graph.php,v 1.4 2006/12/19 18:42:06 nlopess Exp $ */ // File to generate graphs for a weekly or monthly basis @@ -38,38 +39,43 @@ die(basename($_SERVER['PHP_SELF']).": Sorry this file must be called by a cron script.\n"); } -include_once 'lib/jpgraph/jpgraph.php'; -include_once 'lib/jpgraph/jpgraph_line.php'; +// periods for graph generation +$graph_modes = array( + // title, xlabel, SQL period, php func converter (from mysql to x ploting) + 7 => array('Week', 'Day', 'DATE', 'date2day'), + 30 => array('Month', 'Day', 'DATE', 'date2day'), + // 334 = 1 year - 1 month (so that we dont have mixed data with the current and last year month results) + 334 => array('Year', 'Month', 'MONTH', 'month2text') +); -/* -support for: -weekly ( 7 days ) -monthly ( 30 days ) -*/ - -$days = 0; - -if($graph_mode == 'monthly') +function date2day($d) { - $graph_mode_text = 'Month'; - $graph_days = 30; + return substr($d, 8); } -else if($graph_mode == 'weekly') + +function month2text($m) { - $graph_mode_text = 'Week'; - $graph_days = 7; + return date('M', mktime(0, 0, 0, $m)); } +include 'lib/jpgraph/jpgraph.php'; +include 'lib/jpgraph/jpgraph_line.php'; + // make sure the directory exists @mkdir("$outdir/graphs"); -// Make sure an acceptable graph mode is selected before continuing -if($graph_days > 0) +foreach ($graph_modes as $days => $opts) { + gen_graph($days, $opts[0], $opts[1], $opts[2], $opts[3]); +} + + +function gen_graph($graph_days, $graph_mode_text, $xLabel, $sqlgroup, $date2text) { + global $mysqlconn, $version_id, $outdir; try { - $sql = 'SELECT DATE(build_datetime), max( build_percent_code_coverage ) , max( build_numwarnings ) , max( build_numfailures ) , max( build_numleaks ) FROM local_builds WHERE DATE_SUB( CURDATE( ) , INTERVAL ? DAY ) <= build_datetime AND version_id=? GROUP BY DATE(build_datetime)'; + $sql = "SELECT $sqlgroup(build_datetime), max( build_percent_code_coverage ) , max( build_numwarnings ) , max( build_numfailures ) , max( build_numleaks ) FROM local_builds WHERE DATE_SUB( CURDATE( ) , INTERVAL ? DAY ) <= build_datetime AND version_id=? GROUP BY $sqlgroup(build_datetime)"; $stmt = $mysqlconn->prepare($sql); $stmt->execute(array($graph_days, $version_id)); } @@ -106,24 +112,24 @@ while($row = $stmt->fetch()) { - list($build_date, $build_codecoverage, $build_numwarnings, $build_numfailures, $build_numleaks) = $row; + list($date, $build_codecoverage, $build_numwarnings, $build_numfailures, $build_numleaks) = $row; - list($year, $month, $day) = explode('-', $build_date); + $date = $date2text($date); // Code Coverage less then 0 means could not be located if($build_codecoverage >= 0) { $data_y['codecoverage'][] = $build_codecoverage; - $data_x['codecoverage'][] = $day; + $data_x['codecoverage'][] = $date; } $data_y['failures'][] = $build_numfailures; - $data_x['failures'][] = $day; + $data_x['failures'][] = $date; $data_y['memleaks'][] = $build_numleaks; - $data_x['memleaks'][] = $day; + $data_x['memleaks'][] = $date; $data_y['warnings'][] = $build_numwarnings; - $data_x['warnings'][] = $day; + $data_x['warnings'][] = $date; } // Cycle through the results @@ -136,7 +142,7 @@ // Ensure individual graph has enough data to be drawn if(count($data_y[$curgraph['name']]) > 1) { - $graph_filename = $outdir.DIRECTORY_SEPARATOR.'graphs'.DIRECTORY_SEPARATOR.$curgraph['name'].'_'.$graph_mode.'.png'; + $graph_filename = $outdir.DIRECTORY_SEPARATOR.'graphs'.DIRECTORY_SEPARATOR.$curgraph['name'].'_'.$graph_mode_text.'.png'; // Create the graph. These two calls are always required $graph = new Graph(400, 300, 'auto'); @@ -157,7 +163,7 @@ // Add the plot to the graph $graph->Add($lineplot); - $graph->xaxis->SetTitle('Day'); + $graph->xaxis->SetTitle($xLabel); $graph->xaxis->SetTickLabels($data_x[$curgraph['name']]); $graph->xaxis->SetTextTickInterval(1); @@ -174,14 +180,10 @@ echo "graph.php: graph of mode $curgraph[name] had an insufficient number of valid data points.\n"; } // End looping each graph type - echo "graph.php: completed the $graph_mode graph mode\n"; + echo "graph.php: completed the $graph_mode_text graph mode\n"; } // End check that number of rows > 1 else { echo "graph.php: has insufficent data rows to make these graphs for $version_id \n"; } } -else -{ - echo "graph.php was not called with an acceptable mode\n"; -} http://cvs.php.net/viewvc.cgi/php-gcov-web/www/viewer.php?r1=1.2&r2=1.3&diff_format=u Index: php-gcov-web/www/viewer.php diff -u php-gcov-web/www/viewer.php:1.2 php-gcov-web/www/viewer.php:1.3 --- php-gcov-web/www/viewer.php:1.2 Tue Dec 19 15:52:13 2006 +++ php-gcov-web/www/viewer.php Tue Dec 19 18:42:06 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: viewer.php,v 1.2 2006/12/19 15:52:13 nlopess Exp $ */ +/* $Id: viewer.php,v 1.3 2006/12/19 18:42:06 nlopess Exp $ */ // Name: GCOV Viewer page // Desc: page for view PHP version information such as code coverage @@ -94,17 +94,10 @@ // Define the acceptable modes for the graphs $graph_mode_array = array( - 'weekly' => - array( - 'name' => 'weekly', - 'title' => 'Weekly' - ), - 'monthly' => - array( - 'name' => 'monthly', - 'title' => 'Monthly' - ) - ); + 'Week' => 'Weekly', + 'Month' => 'Monthly', + 'Year' => 'Yearly' +); $graph_types_array = array('codecoverage','failures','memleaks','warnings'); @@ -267,8 +260,8 @@ // If date is not set display all available dates if(isset($graph_mode_array[$mode])) { - $appvars['page']['title'] = 'PHP: '.$version.' Last '.$graph_mode_array[$mode]['title'] . ' Graphs'; - $appvars['page']['head'] = 'Last '.$graph_mode_array[$mode]['title']. ' Graphs'; + $appvars['page']['title'] = 'PHP: '.$version.' '.$graph_mode_array[$mode] . ' Graphs'; + $appvars['page']['head'] = $graph_mode_array[$mode]. ' Graphs'; $appvars['page']['headtitle'] = $version; $content .= '<p>The following images show the changes in code coverage, compile warnings, memory leaks and test failures:</p>'; @@ -296,13 +289,13 @@ $appvars['page']['headtitle'] = $version; $content .= <<< HTML -<p>Select the period of time you wish to view as a graphical progression.</p> +<p>Select the period of time you wish to view as a graphical progression:</p> HTML; - foreach($graph_mode_array as $graph_mode) + foreach($graph_mode_array as $idx => $graph_mode) { $content .= <<< HTML -<a href="viewer.php?version=$version&func=graph&mode=$graph_mode[name]">Last $graph_mode[title]</a><br /> +<a href="viewer.php?version=$version&func=graph&mode=$idx">$graph_mode</a><br /> HTML; } } // End check for valid graph mode
« previous php.mirrors (#33558) next »