[csw-devel] SF.net SVN: opencsw:[341] web/wordpresscsw/tools/statistics
wbonnet at users.sourceforge.net
wbonnet at users.sourceforge.net
Sun Feb 27 22:24:28 CET 2011
Revision: 341
http://opencsw.svn.sourceforge.net/opencsw/?rev=341&view=rev
Author: wbonnet
Date: 2011-02-27 21:24:28 +0000 (Sun, 27 Feb 2011)
Log Message:
-----------
Add uwatch statistics
Modified Paths:
--------------
web/wordpresscsw/tools/statistics/db-common.php
Added Paths:
-----------
web/wordpresscsw/tools/statistics/qaUwatchErrors.php
Modified: web/wordpresscsw/tools/statistics/db-common.php
===================================================================
--- web/wordpresscsw/tools/statistics/db-common.php 2011-02-27 16:53:31 UTC (rev 340)
+++ web/wordpresscsw/tools/statistics/db-common.php 2011-02-27 21:24:28 UTC (rev 341)
@@ -306,5 +306,36 @@
return $statCreationUpdate ;
}
+
+ // -----------------------------------------------------------------------------------------------------------------------
+ //
+ // Get the number of uwatch errors for the last 12 rolling months
+ //
+ // -----------------------------------------------------------------------------------------------------------------------
+ function getUwatchErrorsOverLastYear() {
+
+ // Initialize the variables
+ $statUwatch = array(); // array of data that will be returned to caller
+ $statIndex = 0; // current index
+
+ for ($i = 0 ; $i < 52 ; $i ++) {
+ $statUwatch[$i][0] = 0;
+ $statUwatch[$i][1] = 2;
+ $statUwatch[$i][2] = 2011;
+ }
+
+ // Define the query used to retrieve the packages from the database
+ $sqlQuery = "select STU_UWATCH_ERROR_COUNT, STU_MONTH, STU_YEAR from QA_STATS_UWATCH order by ID_STU desc limit 0,52;" ;
+
+ // Execute the query to retrieve the row to update
+ $this->execQuery($sqlQuery);
+
+ // Check if there is a result
+ while ($row = mysql_fetch_array($this->result)) {
+ $statUwatch[$statIndex++] = $row; // Yes there is a record, thus copy it to the array
+ }
+
+ return $statUwatch ;
+ }
}
?>
Added: web/wordpresscsw/tools/statistics/qaUwatchErrors.php
===================================================================
--- web/wordpresscsw/tools/statistics/qaUwatchErrors.php (rev 0)
+++ web/wordpresscsw/tools/statistics/qaUwatchErrors.php 2011-02-27 21:24:28 UTC (rev 341)
@@ -0,0 +1,94 @@
+<?php
+
+ // Includes the graphics library
+ require_once "Artichow/LinePlot.class.php";
+
+ // Include the database parameters
+ require("db-common.php");
+
+ // Defines the function to call for label output
+ function setMonth($value) {
+ global $stats, $labelHashMap;
+
+ date_default_timezone_set('Europe/Paris');
+ $str = date('M', mktime(0,0,0, $stats[51 - $value][1], 1)) . " '";
+ $str .= date('y', mktime(0,0,0,0,1, $stats[51 - $value][2] + 1));
+
+ if (array_key_exists( $str, $labelHashMap)) {
+ return "";
+ } else {
+ $labelHashMap["$str"] = "1";
+ return $str;
+ }
+ }
+
+ function setNumber($value) {
+ return round($value);
+ }
+
+ function labelFormat($value) {
+ return $value;
+ }
+
+ // Initialize the array hashmap
+ $labelHashMap = array() ;
+
+ // Initialization of the graphics
+ $graph = new Graph(800, 480);
+ $graph->setAntiAliasing(FALSE);
+
+ $group = new PlotGroup;
+ $group->grid->setType(Line::DASHED);
+
+ $group->setPadding(40, NULL, 20, NULL);
+
+ $group->axis->left->setLabelNumber(8);
+ $group->axis->left->setLabelPrecision(1);
+ $group->axis->left->setTickStyle(Tick::OUT);
+
+ // Statistics array population
+ $statPackage = array(); // Initialize the number of packages array
+
+ // Create the DAO object
+ $statDAO = new mysqlDAO();
+
+ // Connect to database
+ $statDAO->connect();
+
+ // Retrieve the statistics from the database
+ $stats = $statDAO->getUwatchErrorsOverLastYear();
+
+ // Disconnect from database
+ $statDAO->disconnect();
+
+ for ($idxCounter = 51 ; $idxCounter >= 0 ; $idxCounter--) { // Loop used to copy data
+ $statPackage[$idxCounter] = $stats[51 - $idxCounter][0]; // into the creation array
+ }
+
+ $plot = new LinePlot($statPackage);
+
+ $plot->label->setFont(new Tuffy(7));
+ $plot->label->setPadding(1, 1, 1, 1);
+ $plot->label->setCallbackFunction("labelFormat");
+ $plot->label->setBackgroundColor(
+ new Color(227, 223, 241, 15)
+ );
+ $plot->setColor(new Red());
+ $plot->setFillColor(new LightRed(80));
+
+ $plot->mark->setType(Mark::CIRCLE);
+ $plot->mark->setFill(new MidRed);
+ $plot->mark->setSize(6);
+
+ $group->legend->add($plot, "Number of uWatch errors", Legend::MARK);
+ $group->legend->setPosition(0.35, 0.15);
+ $group->add($plot);
+
+ $group->axis->bottom->label->setCallbackFunction('setMonth');
+ $group->axis->left->label->setCallbackFunction('setNumber');
+
+ $graph->add($group);
+
+ $graph->draw();
+
+?>
Property changes on: web/wordpresscsw/tools/statistics/qaUwatchErrors.php
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list