[Piwik-svn] r145 - in trunk: config modules modules/API modules/ArchiveProcessing modules/DataTable modules/DataTable/Filter modules/ViewDataTable modules/Visualization plugins plugins/Actions plugins/VisitTime plugins/VisitorInterest

svnmaster at piwik.org svnmaster at piwik.org
Fri Jan 11 16:21:09 CET 2008


Author: matt
Date: 2008-01-11 16:21:08 +0100 (Fri, 11 Jan 2008)
New Revision: 145

Modified:
   trunk/config/global.ini.php
   trunk/modules/API/Request.php
   trunk/modules/ArchiveProcessing/Day.php
   trunk/modules/Common.php
   trunk/modules/DataTable/Filter/PatternRecursive.php
   trunk/modules/DataTable/Row.php
   trunk/modules/ViewDataTable.php
   trunk/modules/ViewDataTable/Cloud.php
   trunk/modules/ViewDataTable/GenerateGraphData.php
   trunk/modules/ViewDataTable/Html.php
   trunk/modules/Visualization/Chart.php
   trunk/modules/Visualization/ChartPie.php
   trunk/modules/Visualization/ChartVerticalBar.php
   trunk/plugins/Actions/Controller.php
   trunk/plugins/VisitTime.php
   trunk/plugins/VisitTime/API.php
   trunk/plugins/VisitorInterest.php
   trunk/plugins/VisitorInterest/API.php
Log:
- added possibility to limit the number of elements of a table and distinctly in a graph
- local / server time now have values for all 24h (filled with zeros)

Modified: trunk/config/global.ini.php
===================================================================
--- trunk/config/global.ini.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/config/global.ini.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -52,11 +52,10 @@
 ; this is useful when making changes to the archiving code so we can 
 always_archive_data = false
 
-
 [General]
 ; Time in seconds after which an archive will be computed again. 
 ; This setting is used only for today's statistics.
-time_before_archive_considered_outdated = 30
+time_before_archive_considered_outdated = 300
 
 ; character used to automatically create categories in the "Action" "Downloads" reports
 ; for example a URL like "example.com/blog/development/first-post" will create 

Modified: trunk/modules/API/Request.php
===================================================================
--- trunk/modules/API/Request.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/modules/API/Request.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -131,7 +131,8 @@
 			{
 				$dataTable = $returnedValue;
 				
-				$this->applyDataTableGenericFilters($dataTable);
+				$this->applyDataTableGenericFilters($dataTable);
+				
 				$dataTable->applyQueuedFilters();
 				$toReturn = $this->getRenderedDataTable($dataTable);
 				
@@ -318,7 +319,13 @@
 		 * 3 - Filter that keep only a subset of the results
 		 */
 		$genericFilters = Piwik_API_Request::getGenericFiltersInformation();
-		
+		
+		// if the flag disable_generic_filters is defined we skip the generic filters
+		
+		if(Piwik_Common::getRequestVar('disable_generic_filters', 'false', 'string', $this->requestToUse) != 'false')
+		{
+			return;
+		}
 		foreach($genericFilters as $filterName => $parameters)
 		{
 			$filterParameters = array();

Modified: trunk/modules/ArchiveProcessing/Day.php
===================================================================
--- trunk/modules/ArchiveProcessing/Day.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/modules/ArchiveProcessing/Day.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -181,6 +181,16 @@
 						Piwik_Archive::INDEX_BOUNCE_COUNT 		=> 0
 						);
 	}
+	
+	public function getEmptyInterestRow( $label )
+	{
+		return new Piwik_DataTable_Row(
+				array( 
+					Piwik_DataTable_Row::COLUMNS => 		array(	'label' => $label) 
+															+ $this->getNewInterestRow()
+					)
+				); 
+	}
 	
 	public function updateInterestStats( $newRowToAdd, &$oldRowToUpdate)
 	{		

Modified: trunk/modules/Common.php
===================================================================
--- trunk/modules/Common.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/modules/Common.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -361,9 +361,9 @@
 		$p = strpos($ip, ',');
 		if($p!==false)
 		{
-			return Piwik_Common::sanitizeInputValues(substr($ip, 0, $p));
+			return trim(Piwik_Common::sanitizeInputValues(substr($ip, 0, $p)));
 		}
-		return Piwik_Common::sanitizeInputValues($ip);
+		return trim(Piwik_Common::sanitizeInputValues($ip));
 	}
 	
 		

Modified: trunk/modules/DataTable/Filter/PatternRecursive.php
===================================================================
--- trunk/modules/DataTable/Filter/PatternRecursive.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/modules/DataTable/Filter/PatternRecursive.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -18,14 +18,15 @@
 //		echo $this->table; exit;
 	}
 	
-	protected function filter( $table = null)
+	protected function filter( $table = null )
 	{
 		if(is_null($table))
 		{
 			$table = $this->table;
 		}
-		
-		foreach($table->getRows() as $key => $row)
+		$rows = $table->getRows();
+						
+		foreach($rows as $key => $row)
 		{
 			// A row is deleted if
 			// 1 - its label doesnt contain the pattern 

Modified: trunk/modules/DataTable/Row.php
===================================================================
--- trunk/modules/DataTable/Row.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/modules/DataTable/Row.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -73,7 +73,29 @@
 			unset($idSubtable);
 		}
 	}
-
+
+	public function __toString()
+	{
+		$columns=array();
+		foreach($this->getColumns() as $column => $value)
+		{
+			if(is_string($value)) $value = "'$value'";
+			$columns[] = "'$column' => $value";
+		}
+		$columns = implode(", ", $columns);
+		$details=array();
+
+		foreach($this->getDetails() as $detail => $value)
+		{
+			if(is_string($value)) $value = "'$value'";
+			$details[] = "'$detail' => $value";
+		}
+		$details = implode(", ", $details);
+		$output =  "# [".$columns."] [".$details."] [idsubtable = " 
+					. $this->getIdSubDataTable()."]<br>\n";
+		return $output;
+	}
+	
 	/**
 	 * Returns the given column
 	 * @param string Column name

Modified: trunk/modules/ViewDataTable/Cloud.php
===================================================================
--- trunk/modules/ViewDataTable/Cloud.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/modules/ViewDataTable/Cloud.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -16,7 +16,7 @@
 	
 	public function main()
 	{
-		$this->setDefaultLimit( 30 );
+		$this->setLimit( 30 );
 		if($this->mainAlreadyExecuted)
 		{
 			return;

Modified: trunk/modules/ViewDataTable/GenerateGraphData.php
===================================================================
--- trunk/modules/ViewDataTable/GenerateGraphData.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/modules/ViewDataTable/GenerateGraphData.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -13,7 +13,19 @@
 		$this->disableExcludeLowPopulation();
 		$this->disableSearchBox();
 	}
-	
+	
+	protected $graphLimit;
+	
+	function setGraphLimit( $limit )
+	{
+		$this->graphLimit = $limit;
+	}
+	
+	function getGraphLimit()
+	{
+		return $this->graphLimit;
+	}
+	
 	public function main()
 	{
 		if($this->mainAlreadyExecuted)
@@ -21,11 +33,14 @@
 			return;
 		}
 		$this->mainAlreadyExecuted = true;
-	
-		$this->setDefaultLimit( $this->view->getDefaultLimit() );		
-	
+	
+		
+		$this->setLimit($this->getGraphLimit());
+		
+		// we load the data with the filters applied
 		$this->loadDataTableFromAPI();
-		
+		
+//		echo $this->dataTable;
 		$this->dataAvailable = $this->dataTable->getRowsCount() != 0;
 		
 		if(!$this->dataAvailable)
@@ -33,7 +48,8 @@
 			$this->view->title("No data for this graph", '{font-size: 25px;}');
 		}
 		else
-		{
+		{
+//			echo $this->dataTable;
 			// We apply a filter to the DataTable, decoding the label column (useful for keywords for example)
 			$filter = new Piwik_DataTable_Filter_ColumnCallbackReplace(
 										$this->dataTable, 

Modified: trunk/modules/ViewDataTable/Html.php
===================================================================
--- trunk/modules/ViewDataTable/Html.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/modules/ViewDataTable/Html.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -113,11 +113,6 @@
 		return false;
 	}
 
-	public function setSortedColumn( $columnId, $order = 'desc')
-	{
-		$this->variablesDefault['filter_sort_column']= $columnId;
-		$this->variablesDefault['filter_sort_order']= $order;
-	}
 	
 
 	public function setSearchRecursive()

Modified: trunk/modules/ViewDataTable.php
===================================================================
--- trunk/modules/ViewDataTable.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/modules/ViewDataTable.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -233,7 +233,8 @@
 			{
 				$requestString .= '&'.$varToSet.'='.$value;
 			}
-		}
+		}
+//		echo $requestString;exit;
 		// We finally make the request to the API
 		$request = new Piwik_API_Request($requestString);
 		
@@ -270,7 +271,6 @@
 		return $this->variablesDefault[$nameVar];
 	}
 	
-	
 	public function disableSort()
 	{
 		$this->JSsortEnabled = 'false';		
@@ -328,10 +328,17 @@
 			= $this->variablesDefault['filter_excludelowpop_value']
 			= $value;	
 	}
-	
-	public function setDefaultLimit( $limit )
+
+	public function setLimit( $limit )
 	{
-		$this->variablesDefault['filter_limit'] = $limit;
+		if($limit != 0)
+		{
+			$this->variablesDefault['filter_limit'] = $limit;
+		}
 	}
-
+	public function setSortedColumn( $columnId, $order = 'desc')
+	{
+		$this->variablesDefault['filter_sort_column']= $columnId;
+		$this->variablesDefault['filter_sort_order']= $order;
+	}
 }
\ No newline at end of file

Modified: trunk/modules/Visualization/Chart.php
===================================================================
--- trunk/modules/Visualization/Chart.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/modules/Visualization/Chart.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -2,8 +2,6 @@
 require_once "Visualization/OpenFlashChart.php";
 abstract class Piwik_Visualization_Chart extends Piwik_Visualization_OpenFlashChart
 {
-	abstract function getDefaultLimit();
-	
 	function setData($data)
 	{
 		$this->dataGraph = $data;
@@ -11,7 +9,8 @@
 	
 	function prepareData()
 	{		
-		$label = $data = array();
+		$label = $data = array();
+//		var_dump($this->dataGraph);
 		foreach($this->dataGraph as $row)
 		{
 			$label[] = $row['label'];

Modified: trunk/modules/Visualization/ChartPie.php
===================================================================
--- trunk/modules/Visualization/ChartPie.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/modules/Visualization/ChartPie.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -2,10 +2,6 @@
 require_once "Visualization/Chart.php";
 class Piwik_Visualization_ChartPie extends Piwik_Visualization_Chart
 {
-	function getDefaultLimit()
-	{
-		return 5;
-	}
 	function customizeGraph()
 	{
 		$this->prepareData();		

Modified: trunk/modules/Visualization/ChartVerticalBar.php
===================================================================
--- trunk/modules/Visualization/ChartVerticalBar.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/modules/Visualization/ChartVerticalBar.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -1,11 +1,9 @@
 <?php
 require_once "Visualization/Chart.php";
 class Piwik_Visualization_ChartVerticalBar extends Piwik_Visualization_Chart
-{
-	function getDefaultLimit()
-	{
-		return 10;
-	}
+{
+	protected $limit = 10;
+		
 	function customizeGraph()
 	{
 		$this->prepareData();

Modified: trunk/plugins/Actions/Controller.php
===================================================================
--- trunk/plugins/Actions/Controller.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/plugins/Actions/Controller.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -16,7 +16,7 @@
 		$view->disableSort();
 		$view->disableOffsetInformation();
 		
-		$view->setDefaultLimit( 10 );
+		$view->setLimit( 10 );
 		
 		return $this->renderView($view, $fetch);
 	}

Modified: trunk/plugins/VisitTime/API.php
===================================================================
--- trunk/plugins/VisitTime/API.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/plugins/VisitTime/API.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -27,6 +27,7 @@
 		//$dataTable->queueFilter('Piwik_DataTable_Filter_Sort', array('label', 'asc'));
 		$dataTable->queueFilter('Piwik_DataTable_Filter_ColumnCallbackReplace', array('label', 'Piwik_getTimeLabel'));
 		$dataTable->queueFilter('Piwik_DataTable_Filter_ReplaceColumnNames');
+		
 		
 		return $dataTable;
 	}

Modified: trunk/plugins/VisitTime.php
===================================================================
--- trunk/plugins/VisitTime.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/plugins/VisitTime.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -52,18 +52,33 @@
 	public function archiveDay( $notification )
 	{
 		$archiveProcessing = $notification->getNotificationObject();
-
+
+		$this->archiveProcessing = $archiveProcessing;
+		
 		$recordName = 'VisitTime_localTime';
 		$labelSQL = "HOUR(visitor_localtime)";
 		$tableLocalTime = $archiveProcessing->getDataTableInterestForLabel($labelSQL);
-		
+		$this->makeSureAllHoursAreSet($tableLocalTime);
 		$record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tableLocalTime->getSerialized());
 //		echo $tableLocalTime;
 		
 		$recordName = 'VisitTime_serverTime';
 		$labelSQL = "HOUR(visit_first_action_time)";
-		$tableServerTime = $archiveProcessing->getDataTableInterestForLabel($labelSQL);
+		$tableServerTime = $archiveProcessing->getDataTableInterestForLabel($labelSQL);
+		$this->makeSureAllHoursAreSet($tableServerTime);
 		$record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tableServerTime->getSerialized());
 //		echo $tableServerTime;
+	}
+	
+	private function makeSureAllHoursAreSet($table)
+	{
+		for($i=0;$i<=23;$i++)
+		{
+			if($table->getRowFromLabel($i) === false)
+			{
+				$row = $this->archiveProcessing->getEmptyInterestRow($i);
+				$table->addRow( $row );
+			}
+		}
 	}
 }
\ No newline at end of file

Modified: trunk/plugins/VisitorInterest/API.php
===================================================================
--- trunk/plugins/VisitorInterest/API.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/plugins/VisitorInterest/API.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -23,7 +23,8 @@
 	{
 		Piwik::checkUserHasViewAccess( $idSite );
 		$archive = Piwik_Archive::build($idSite, $date, $period );
-		$dataTable = $archive->getDataTable('VisitorInterest_timeGap');
+		$dataTable = $archive->getDataTable('VisitorInterest_timeGap');
+		
 		$dataTable->queueFilter('Piwik_DataTable_Filter_ReplaceColumnNames');
 		$dataTable->queueFilter('Piwik_DataTable_Filter_Sort', array('label', 'asc', true));
 		$dataTable->queueFilter('Piwik_DataTable_Filter_ColumnCallbackReplace', array('label', 'Piwik_getDurationLabel'));

Modified: trunk/plugins/VisitorInterest.php
===================================================================
--- trunk/plugins/VisitorInterest.php	2008-01-11 14:59:23 UTC (rev 144)
+++ trunk/plugins/VisitorInterest.php	2008-01-11 15:21:08 UTC (rev 145)
@@ -127,10 +127,8 @@
 				$minGap = $gap[0] * 60;
 				$maxGap = $gap[1] * 60;
 				
-				if($minGap == 0 || $minGap == 0.5)
-				{
-					$gapName = "'".$minGap."-".$maxGap."'";
-				}
+				
+				$gapName = "'".$minGap."-".$maxGap."'";
 				$select[] = "sum(case when visit_total_time between $minGap and $maxGap then 1 else 0 end) as $gapName ";
 			}
 			else
@@ -142,6 +140,8 @@
 		}		
 		$toSelect = implode(" , ", $select);
 		
-		return $this->archiveProcessing->getSimpleDataTableFromSelect($toSelect, Piwik_Archive::INDEX_NB_VISITS);
+		$table = $this->archiveProcessing->getSimpleDataTableFromSelect($toSelect, Piwik_Archive::INDEX_NB_VISITS);
+//		echo $table;
+		return $table;
 	}
 }
\ No newline at end of file



More information about the Piwik-svn mailing list