[llvm-commits] [nightly-test-server] r59980 - /nightly-test-server/trunk/locgraph.php

Misha Brukman brukman+llvm at gmail.com
Mon Nov 24 12:37:23 PST 2008


Author: brukman
Date: Mon Nov 24 14:37:23 2008
New Revision: 59980

URL: http://llvm.org/viewvc/llvm-project?rev=59980&view=rev
Log:
* s/CVS/SVN/
* Cleaned up some code and formatting
* Realized that PHP debugging leaves a lot to be desired
* Noticed that PHP, as a language, does the same

Modified:
    nightly-test-server/trunk/locgraph.php

Modified: nightly-test-server/trunk/locgraph.php
URL: http://llvm.org/viewvc/llvm-project/nightly-test-server/trunk/locgraph.php?rev=59980&r1=59979&r2=59980&view=diff

==============================================================================
--- nightly-test-server/trunk/locgraph.php (original)
+++ nightly-test-server/trunk/locgraph.php Mon Nov 24 14:37:23 2008
@@ -4,70 +4,52 @@
 include("jpgraph/jpgraph_utils.inc");
 include("jpgraph/jpgraph_date.php");
 
-if(isset($HTTP_GET_VARS['start'])){
-	$start = $HTTP_GET_VARS['start'];
-}
-if(isset($HTTP_GET_VARS['end'])){
-	$end = $HTTP_GET_VARS['end'];
-}
-
-$locgraphlink=mysql_connect("localhost","llvm","ll2002vm");
+$locgraphlink = mysql_connect("localhost", "llvm", "ll2002vm");
 mysql_select_db("nightlytestresults");
 
-
-$lines  = array();
+$lines = array();
 $files = array();
 $dirs = array();
 $xdata = array();
 
-/********************************
- *
- * This is where we choose the bounds on the graph
- * 
- ********************************/
-if(isset($start) && isset($end)){
-	$query = mysql_query("select * from code where added <= \"$end\" and added >= \"$start\" order by added desc") or die (mysql_error());
-}
-else if(!isset($start) && isset($end)){
-	$query = mysql_query("select * from code where added <=\"$end\" order by added desc") or die (mysql_error());
-}	
-else if(isset($start) && !isset($end)){
-	$query = mysql_query("select * from code where added >= \"$start\" order by added desc") or die (mysql_error());
-}
-else{
-	$query = mysql_query("select * from code order by added desc") or die (mysql_error());
-}
-
-if(isset($HTTP_GET_VARS['xsize'])){
-	$xsize = $HTTP_GET_VARS['xsize'];
-}
-else{
-	$xsize=400;
-}
-
-if(isset($HTTP_GET_VARS['ysize'])){
-	$ysize = $HTTP_GET_VARS['ysize'];
-}
-else{
-	$ysize=250;
-}
-
-
-while($row = mysql_fetch_array($query)){
-	array_push($lines, $row['loc']);
-	#array_push($dirs, $row['dirs']);
-	#array_push($files, $row['files']);
-	preg_match("/(\d\d\d\d)\-(\d\d)\-(\d\d)\s(\d\d)\:(\d\d)\:(\d\d)/", $row['added'], $values);
-	$seconds = mktime($values[4], $values[5], $values[6], $values[2], $values[3],$values[1]);
-	array_push($xdata, $seconds);
-}
-
-function  TimeCallback( $aVal) {
-    return Date ('m-d-y', $aVal);
-}
-$graph = new Graph($xsize,$ysize);
+function GetSqlQuery() {
+  if (isset($HTTP_GET_VARS['start'])) {
+    $start = $HTTP_GET_VARS['start'];
+  }
+  if (isset($HTTP_GET_VARS['end'])) {
+    $end = $HTTP_GET_VARS['end'];
+  }
+  $query_tpl = "SELECT * FROM code %s ORDER BY added DESC";
+  if (isset($start) && isset($end)) {
+    return sprintf($query_tpl, "WHERE added <= \"$end\" AND added >= \"$start\"");
+  } else if (!isset($start) && isset($end)) {
+    return sprintf($query_tpl, "WHERE added <=\"$end\"");
+  } else if (isset($start) && !isset($end)) {
+    return sprintf($query_tpl, "WHERE added >= \"$start\"");
+  } else {
+    return sprintf($query_tpl, "");
+  }
+}
+
+$sql_data = mysql_query(GetSqlQuery()) or die(mysql_error());
+while ($row = mysql_fetch_array($sql_data)) {
+  array_push($lines, $row['loc']);
+  #array_push($dirs, $row['dirs']);
+  #array_push($files, $row['files']);
+  preg_match("/(\d\d\d\d)\-(\d\d)\-(\d\d)\s(\d\d)\:(\d\d)\:(\d\d)/", $row['added'], $values);
+  $seconds = mktime($values[4], $values[5], $values[6], $values[2], $values[3], $values[1]);
+  array_push($xdata, $seconds);
+}
+
+function TimeCallback($aVal) {
+  return Date('m-d-y', $aVal);
+}
+
+$xsize = isset($HTTP_GET_VARS['xsize']) ? $HTTP_GET_VARS['xsize'] : 400;
+$ysize = isset($HTTP_GET_VARS['ysize']) ? $HTTP_GET_VARS['ysize'] : 250;
+$graph = new Graph($xsize, $ysize);
 $graph->SetScale("datelin");
-$graph->tabtitle->Set(" Lines of Code in CVS Repository ");
+$graph->tabtitle->Set(" Lines of Code in SVN Repository ");
 #$graph->tabtitle->SetFont(FF_ARIAL,FS_BOLD,13);
 $graph->xaxis->SetLabelAngle(90);
 $graph->SetMargin(70,40,30,80);
@@ -75,13 +57,13 @@
 $graph->yaxis->title->SetMargin(30);
 $graph->SetFrame(false);
 $graph->SetMarginColor("White");
-$graph->legend->SetShadow('gray at 0.4',5);
-$graph->legend->SetPos(0.2,0.13,'left','top');
+$graph->legend->SetShadow('gray at 0.4', 5);
+$graph->legend->SetPos(0.2, 0.13, 'left', 'top');
 $graph->legend->hide(true);
-$graph->ygrid->SetFill(true,'#EFEFEF at 0.5','#BBCCFF at 0.5');
+$graph->ygrid->SetFill(true, '#EFEFEF at 0.5', '#BBCCFF at 0.5');
 $graph->xgrid->Show();
 $graph->xaxis->scale->SetTimeAlign(MONTHADJ_1);
-$graph->xaxis-> SetLabelFormatCallback( 'TimeCallback');
+$graph->xaxis->SetLabelFormatCallback('TimeCallback');
 
 $line = new LinePlot($lines, $xdata);
 $line->SetLegend("Lines of code");





More information about the llvm-commits mailing list