[Piwik-svn] r176 - in trunk: modules modules/ArchiveProcessing modules/DataFiles modules/DataTable/Row plugins
svnmaster at piwik.org
svnmaster at piwik.org
Tue Jan 15 05:59:51 CET 2008
Author: matt
Date: 2008-01-15 05:59:50 +0100 (Tue, 15 Jan 2008)
New Revision: 176
Modified:
trunk/modules/Archive.php
trunk/modules/ArchiveProcessing.php
trunk/modules/ArchiveProcessing/Day.php
trunk/modules/DataFiles/SearchEngines.php
trunk/modules/DataTable/Row/DataTableSummary.php
trunk/plugins/VisitTime.php
Log:
- commenting, thinking about #38 ....
Modified: trunk/modules/Archive.php
===================================================================
--- trunk/modules/Archive.php 2008-01-15 01:46:20 UTC (rev 175)
+++ trunk/modules/Archive.php 2008-01-15 04:59:50 UTC (rev 176)
@@ -45,7 +45,8 @@
protected $id = null;
protected $isThereSomeVisits = false;
protected $alreadyChecked = false;
- protected $archiveProcessing = null;
+ protected $archiveProcessing = null;
+ protected $blobCached = array();
protected $cacheEnabledForNumeric = true;
@@ -54,7 +55,15 @@
}
static protected $alreadyBuilt = array();
-
+
+ /**
+ * Builds an Archive object or returns the same archive if previously built.
+ *
+ * @param int $idSite
+ * @param string $date 'YYYY-MM-DD' or magic keywords 'today' See Piwik_Date::factory
+ * @param string $period 'week' 'day' etc.
+ * @return Piwik_Archive
+ */
static public function build($idSite, $date, $period )
{
$oDate = Piwik_Date::factory($date);
@@ -74,22 +83,249 @@
self::$alreadyBuilt[$idSite][$date][$period] = $archive;
return $archive;
}
+
+ /**
+ * Returns the value of the element $name from the current archive
+ * The value to be returned is a numeric value and is stored in the archive_numeric_* tables
+ *
+ * @param string $name For example Referers_distinctKeywords
+ * @return float|int|false False if no value with the given name
+ */
+ public function getNumeric( $name )
+ {
+ // we cast the result as float because returns false when no visitors
+ return (float)$this->get($name, 'numeric');
+ }
+
+ /**
+ * Returns the value of the element $name from the current archive
+ *
+ * The value to be returned is a blob value and is stored in the archive_numeric_* tables
+ *
+ * It can return anything from strings, to serialized PHP arrays or PHP objects, etc.
+ *
+ * @param string $name For example Referers_distinctKeywords
+ * @return mixed False if no value with the given name
+ */
+ public function getBlob( $name )
+ {
+ return $this->get($name, 'blob');
+ }
+
+ /**
+ * Given a list of fields defining numeric values, it will return a Piwik_DataTable_Simple
+ * containing one row per value.
+ *
+ * For example $fields = array( 'max_actions',
+ * 'nb_uniq_visitors',
+ * 'nb_visits',
+ * 'nb_actions',
+ * 'sum_visit_length',
+ * 'bounce_count',
+ * );
+ *
+ * @param array $fields array( fieldName1, fieldName2, ...)
+ * @return Piwik_DataTable_Simple
+ */
+ public function getDataTableFromNumeric( $fields )
+ {
+ require_once "DataTable/Simple.php";
+ if(!is_array($fields))
+ {
+ $fields = array($fields);
+ }
+
+ $values = array();
+ foreach($fields as $field)
+ {
+ $values[$field] = $this->getNumeric($field);
+ }
+
+ $table = new Piwik_DataTable_Simple;
+ $table->loadFromArray($values);
+ return $table;
+ }
+
+ /**
+ * This method will build a dataTable from the blob value $name in the current archive.
+ *
+ * For example $name = 'Referers_searchEngineByKeyword' will return a Piwik_DataTable containing all the keywords
+ * If a idSubTable is given, the method will return the subTable of $name
+ *
+ * @param string $name
+ * @param int $idSubTable
+ * @return Piwik_DataTable
+ * @throws exception If the value cannot be found
+ */
+ public function getDataTable( $name, $idSubTable = null )
+ {
+ if(!is_null($idSubTable))
+ {
+ $name .= "_$idSubTable";
+ }
+
+ $data = $this->get($name, 'blob');
+
+ $table = new Piwik_DataTable;
+
+ if($data !== false)
+ {
+ $table->loadFromSerialized($data);
+ }
+
+ if($data === false
+ && $idSubTable !== null)
+ {
+ throw new Exception("You are requesting a precise subTable but there is not such data in the Archive.");
+ }
+
+ return $table;
+ }
+
+ /**
+ * Same as getDataTable() except that it will also load in memory
+ * all the subtables for the DataTable $name.
+ * You can then access the subtables by using the Piwik_DataTable_Manager getTable()
+ *
+ * @param string $name
+ * @param int $idSubTable
+ * @return Piwik_DataTable
+ */
+ public function getDataTableExpanded($name, $idSubTable = null)
+ {
+ $this->preFetchBlob($name);
+ $dataTableToLoad = $this->getDataTable($name, $idSubTable);
+ $this->loadSubDataTables($name, $dataTableToLoad, $addDetailSubtableId = true);
+ return $dataTableToLoad;
+ }
+
+ /**
+ * Returns a value from the current archive with the name = $name
+ * Method used by getNumeric or getBlob
+ *
+ * @param string $name
+ * @param string $typeValue numeric|blob
+ * @return mixed|false if no result
+ */
+ protected function get( $name, $typeValue = 'numeric' )
+ {
+ // values previously "get" and now cached
+ if($typeValue == 'numeric'
+ && $this->cacheEnabledForNumeric
+ && isset($this->numericCached[$name])
+ )
+ {
+ return $this->numericCached[$name];
+ }
+
+ // During archiving we prefetch the blobs recursively
+ // and we get them faster from memory after
+ if($typeValue == 'blob'
+ && isset($this->blobCached[$name]))
+ {
+ return $this->blobCached[$name];
+ }
+
+ $this->prepareArchive();
+
+ if($name == 'idarchive')
+ {
+ return $this->idArchive;
+ }
+
+// Piwik::log("-- get '$name'");
+
+ if(!$this->isThereSomeVisits)
+ {
+ return false;
+ }
+
+ // select the table to use depending on the type of the data requested
+ switch($typeValue)
+ {
+ case 'blob':
+ $table = $this->archiveProcessing->getTableArchiveBlobName();
+ break;
+
+ case 'numeric':
+ default:
+ $table = $this->archiveProcessing->getTableArchiveNumericName();
+ break;
+ }
+
+ // we select the requested value
+ $db = Zend_Registry::get('db');
+ $value = $db->fetchOne("SELECT value
+ FROM $table
+ WHERE idarchive = ?
+ AND name = ?",
+ array( $this->idArchive , $name)
+ );
+
+ // no result, returns false
+ if($value === false)
+ {
+ if($typeValue == 'numeric'
+ && $this->cacheEnabledForNumeric)
+ {
+ // we cache the results
+ $this->numericCached[$name] = false;
+ }
+ return $value;
+ }
+
+ // uncompress when selecting from the BLOB table
+ if($typeValue == 'blob')
+ {
+ $value = gzuncompress($value);
+ }
+
+ if($typeValue == 'numeric'
+ && $this->cacheEnabledForNumeric)
+ {
+ // we cache the results
+ $this->numericCached[$name] = $value;
+ }
+ return $value;
+ }
- // to be used only once
+ /**
+ * Set the period
+ *
+ * @param Piwik_Period $period
+ */
public function setPeriod( Piwik_Period $period )
{
$this->period = $period;
}
-
- function setSite( Piwik_Site $site )
+
+ /**
+ * Set the site
+ *
+ * @param Piwik_Site $site
+ */
+ public function setSite( Piwik_Site $site )
{
$this->site = $site;
}
- function getIdSite()
+
+ /**
+ * Returns the Id site associated with this archive
+ *
+ * @return int
+ */
+ public function getIdSite()
{
return $this->site->getId();
}
-
+
+ /**
+ * Prepares the archive. Gets the idarchive from the ArchiveProcessing.
+ *
+ * This will possibly launch the archiving process if the archive was not available.
+ *
+ * @return void
+ */
public function prepareArchive()
{
if(!$this->alreadyChecked)
@@ -116,185 +352,65 @@
}
}
- public function get( $name, $typeValue = 'numeric' )
- {
- // values previously "get" and now cached
- if($typeValue == 'numeric'
- && $this->cacheEnabledForNumeric
- && isset($this->numericCached[$name])
- )
- {
- return $this->numericCached[$name];
- }
-
- // Values prefetched
- if($typeValue == 'blob'
- && isset($this->blobCached[$name]))
- {
- return $this->blobCached[$name];
- }
-
- $this->prepareArchive();
-
- if($name == 'idarchive')
- {
- return $this->idArchive;
- }
-
-// Piwik::log("-- get '$name'");
-
- if(!$this->isThereSomeVisits)
- {
- return false;
- }
-
- // select the table to use depending on the type of the data requested
- switch($typeValue)
- {
- case 'blob':
- $table = $this->archiveProcessing->getTableArchiveBlobName();
- break;
-
- case 'numeric':
- default:
- $table = $this->archiveProcessing->getTableArchiveNumericName();
- break;
- }
-
- // we select the requested value
- $db = Zend_Registry::get('db');
- $value = $db->fetchOne("SELECT value
- FROM $table
- WHERE idarchive = ?
- AND name = ?",
- array( $this->idArchive , $name)
- );
-
- // no result, returns false
- if($value === false)
- {
- if($typeValue == 'numeric'
- && $this->cacheEnabledForNumeric)
- {
- // we cache the results
- $this->numericCached[$name] = false;
- }
- return $value;
- }
-
- // uncompress when selecting from the BLOB table
- if($typeValue == 'blob')
- {
- $value = gzuncompress($value);
- }
-
- if($typeValue == 'numeric'
- && $this->cacheEnabledForNumeric)
- {
- // we cache the results
- $this->numericCached[$name] = $value;
- }
- return $value;
+ /**
+ * This method loads in memory all the subtables for the main table called $name.
+ * You have to give it the parent table $dataTableToLoad so we can lookup the sub tables ids to load.
+ *
+ * If $addDetailSubtableId set to true, it will add for each row a 'detail' called 'databaseSubtableId'
+ * containing the child ID of the subtable associated to this row.
+ *
+ * @param string $name
+ * @param Piwik_DataTable $dataTableToLoad
+ * @param bool $addDetailSubtableId
+ *
+ * @return void
+ */
+ public function loadSubDataTables($name, Piwik_DataTable $dataTableToLoad, $addDetailSubtableId = false)
+ {
+ // we have to recursively load all the subtables associated to this table's rows
+ // and update the subtableID so that it matches the newly instanciated table
+ foreach($dataTableToLoad->getRows() as $row)
+ {
+ $subTableID = $row->getIdSubDataTable();
+
+ if($subTableID !== null)
+ {
+ $subDataTableLoaded = $this->getDataTable($name, $subTableID);
+
+ $this->loadSubDataTables($name, $subDataTableLoaded);
+
+ // we edit the subtable ID so that it matches the newly table created in memory
+ // NB:
+ // we dont do that in the case we are displaying the table expanded.
+ // in this case we wan't the user to see the REAL dataId in the database
+ if($addDetailSubtableId)
+ {
+ $row->addDetail('databaseSubtableId', $row->getIdSubDataTable());
+ }
+ $row->setSubtable( $subDataTableLoaded );
+ }
+ }
}
+
+
-
- public function loadSubDataTables($name, Piwik_DataTable $dataTableToLoad, $addDetailSubtableId = false)
- {
- // we have to recursively load all the subtables associated to this table's rows
- // and update the subtableID so that it matches the newly instanciated table
- foreach($dataTableToLoad->getRows() as $row)
- {
- $subTableID = $row->getIdSubDataTable();
-
- if($subTableID !== null)
- {
- $subDataTableLoaded = $this->getDataTable($name, $subTableID);
-
- $this->loadSubDataTables($name, $subDataTableLoaded);
-
- // we edit the subtable ID so that it matches the newly table created in memory
- // NB:
- // we dont do that in the case we are displaying the table expanded.
- // in this case we wan't the user to see the REAL dataId in the database
- if($addDetailSubtableId)
- {
- $row->addDetail('databaseSubtableId', $row->getIdSubDataTable());
- }
- $row->setSubtable( $subDataTableLoaded );
- }
- }
- }
-
- public function getDataTableExpanded($name, $idSubTable = null)
- {
- $this->preFetchBlob($name);
- $dataTableToLoad = $this->getDataTable($name, $idSubTable);
- $this->loadSubDataTables($name, $dataTableToLoad, $addDetailSubtableId = true);
- return $dataTableToLoad;
- }
-
- public function getDataTable( $name, $idSubTable = null )
- {
- if(!is_null($idSubTable))
- {
- $name .= "_$idSubTable";
- }
-
- $data = $this->get($name, 'blob');
-
- $table = new Piwik_DataTable;
-
- if($data !== false)
- {
- $table->loadFromSerialized($data);
- }
-
- if($data === false
- && $idSubTable !== null)
- {
- throw new Exception("You are requesting a precise subTable but there is not such data in the Archive.");
- }
-
- return $table;
- }
-
- public function getDataTableFromNumeric( $fields )
- {
- require_once "DataTable/Simple.php";
- if(!is_array($fields))
- {
- $fields = array($fields);
- }
-
- $values = array();
- foreach($fields as $field)
- {
- $values[$field] = $this->getNumeric($field);
- }
-
- $table = new Piwik_DataTable_Simple;
- $table->loadFromArray($values);
- return $table;
- }
-
-
- public function getNumeric( $name )
- {
- // we caste the result as float because returns false when no visitors
- return (float)$this->get($name, 'numeric');
- }
-
- public function getBlob( $name )
- {
- return $this->get($name, 'blob');
- }
-
+ /**
+ * Free the blob cache memory array
+ *
+ * @return void
+ */
public function freeBlob( $name )
{
-
+ // we delete the blob
+ $this->blobCached = null;
+ $this->blobCached = array();
}
- // fetches all blob fields name_* at once for performance
+ /**
+ * Fetches all blob fields name_* at once for the current archive for performance reasons.
+ *
+ * @return void
+ */
public function preFetchBlob( $name )
{
// Piwik::log("-- prefetch blob ".$name."_*");
Modified: trunk/modules/ArchiveProcessing/Day.php
===================================================================
--- trunk/modules/ArchiveProcessing/Day.php 2008-01-15 01:46:20 UTC (rev 175)
+++ trunk/modules/ArchiveProcessing/Day.php 2008-01-15 04:59:50 UTC (rev 176)
@@ -21,7 +21,9 @@
*/
class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing
{
-
+ /**
+ * Constructor
+ */
function __construct()
{
parent::__construct();
@@ -29,15 +31,11 @@
}
/**
- * Reads the log and compute the essential reports.
- * All the non essential reports are computed inside plugins.
- *
- * One record is either a numeric value or a BLOB which is
- * usually a compressed serialized DataTable.
- *
- * At the end of the process we add a fake record called 'done' that flags
- * the archive as being valid.
- *
+ * Main method to process logs for a day. The only logic done here is computing the number of visits, actions, etc.
+ * All the otherreports are computed inside plugins listening to the event 'ArchiveProcessing_Day.compute'.
+ * See some of the plugins for example.
+ *
+ * @return void
*/
protected function compute()
{
@@ -67,7 +65,24 @@
Piwik_PostEvent('ArchiveProcessing_Day.compute', $this);
}
-
+
+ /**
+ * Helper function that returns a DataTable containing the $select fields / value pairs.
+ * IMPORTANT: The $select must return only one row!!
+ *
+ * Example $select = "count(distinct( config_os )) as countDistinctOs,
+ * sum( config_flash ) / count(distinct(idvisit)) as percentFlash "
+ * $labelCount = "test_column_name"
+ * will return a dataTable that looks like
+ * label test_column_name
+ * CountDistinctOs 9
+ * PercentFlash 0.5676
+ *
+ *
+ * @param string $select
+ * @param string $labelCount
+ * @return Piwik_DataTable
+ */
public function getSimpleDataTableFromSelect($select, $labelCount)
{
$query = "SELECT $select
@@ -82,12 +97,32 @@
}
$table = new Piwik_DataTable;
$table->loadFromArrayLabelIsKey($data);
-// echo $table;
-// exit;
return $table;
}
-
+ /**
+ * Helper function that returns common statistics for a given database field distinct values.
+ *
+ * The statistics returned are:
+ * - number of unique visitors
+ * - number of visits
+ * - number of actions
+ * - maximum number of action for a visit
+ * - sum of the visits' length in sec
+ * - count of bouncing visits (visits with one page view)
+ *
+ * For example if $label = 'config_os' it will return the statistics for every distinct Operating systems
+ * The returned DataTable will have a row per distinct operating systems,
+ * and a column per stat (nb of visits, max actions, etc)
+ *
+ * label nb_unique_visitors nb_visits nb_actions max_actions sum_visit_length bounce_count
+ * Linux 27 66 66 1 660 66
+ * Windows XP 12 39 39 1 390 39
+ * Mac OS 15 36 36 1 360 36
+ *
+ * @param string $label Table log_visit field name to be use to compute common stats
+ * @return Piwik_DataTable
+ */
public function getDataTableInterestForLabel( $label )
{
$query = "SELECT $label as label,
@@ -125,7 +160,15 @@
$table->loadFromArrayLabelIsKey($interest);
return $table;
}
-
+
+ /**
+ * Generates a dataTable given a multidimensional PHP array that associates LABELS to Piwik_DataTableRows
+ * This is used for the "Actions" DataTable, where a line is the aggregate of all the subtables
+ * Example: the category /blog has 3 visits because it has /blog/index (2 visits) + /blog/about (1 visit)
+ *
+ * @param array $table
+ * @return Piwik_DataTable
+ */
static public function generateDataTable( $table )
{
$dataTableToReturn = new Piwik_DataTable;
@@ -153,7 +196,18 @@
return $dataTableToReturn;
}
-
+
+ /**
+ * Helper function that returns the serialized DataTable of the given PHP array.
+ * The array must have the format of Piwik_DataTable::loadFromArrayLabelIsKey()
+ * Example: array (
+ * LABEL => array(col1 => X, col2 => Y),
+ * LABEL2 => array(col1 => X, col2 => Y),
+ * )
+ *
+ * @param array $array at the given format
+ * @return array Array with one element: the serialized data table string
+ */
public function getDataTableSerialized( $arrayLevel0 )
{
$table = new Piwik_DataTable;
@@ -162,7 +216,30 @@
return $toReturn;
}
-
+
+ /**
+ * Helper function that returns the multiple serialized DataTable of the given PHP array.
+ * The DataTable here associates a subtable to every row of the level 0 array.
+ * This is used for example for search engines. Every search engine (level 0) has a subtable containing the
+ * keywords.
+ *
+ * The $arrayLevel0 must have the format
+ * Example: array (
+ * LABEL => array(col1 => X, col2 => Y),
+ * LABEL2 => array(col1 => X, col2 => Y),
+ * )
+ *
+ * The $subArrayLevel1ByKey must have the format
+ * Example: array(
+ * LABEL => #Piwik_DataTable_ForLABEL,
+ * LABEL2 => #Piwik_DataTable_ForLABEL2,
+ * )
+ *
+ *
+ * @param array $arrayLevel0
+ * @param array of Piwik_DataTable $subArrayLevel1ByKey
+ * @return array Array with N elements: the strings of the datatable serialized
+ */
public function getDataTablesSerialized( $arrayLevel0, $subArrayLevel1ByKey)
{
$tablesByLabel = array();
@@ -181,7 +258,12 @@
return $toReturn;
}
-
+
+ /**
+ * Returns an empty row containing default values for the common stat
+ *
+ * @return array
+ */
public function getNewInterestRow()
{
return array( Piwik_Archive::INDEX_NB_UNIQ_VISITORS => 0,
@@ -193,7 +275,15 @@
);
}
- public function getEmptyInterestRow( $label )
+
+ /**
+ * Returns a Piwik_DataTable_Row containing default values for common stat,
+ * plus a column 'label' with the value $label
+ *
+ * @param string $label
+ * @return Piwik_DataTable_Row
+ */
+ public function getNewInterestRowLabeled( $label )
{
return new Piwik_DataTable_Row(
array(
@@ -202,7 +292,15 @@
)
);
}
-
+
+ /**
+ * Adds the given row $newRowToAdd to the existing $oldRowToUpdate passed by reference
+ *
+ * The rows are php arrays Name => value
+ *
+ * @param array $newRowToAdd
+ * @param array $oldRowToUpdate
+ */
public function updateInterestStats( $newRowToAdd, &$oldRowToUpdate)
{
$oldRowToUpdate[Piwik_Archive::INDEX_NB_UNIQ_VISITORS] += $newRowToAdd[Piwik_Archive::INDEX_NB_UNIQ_VISITORS];
Modified: trunk/modules/ArchiveProcessing.php
===================================================================
--- trunk/modules/ArchiveProcessing.php 2008-01-15 01:46:20 UTC (rev 175)
+++ trunk/modules/ArchiveProcessing.php 2008-01-15 04:59:50 UTC (rev 176)
@@ -36,21 +36,46 @@
protected $idArchive;
- protected $periodId;
- protected $dateStart;
- protected $dateEnd;
- protected $tableArchiveNumeric;
- protected $tableArchiveBlob;
+ protected $periodId;
+
+
+ /**
+ * @var Piwik_Date
+ */
+ protected $dateStart;
+ /**
+ * @var Piwik_Date
+ */
+ protected $dateEnd;
+
+ /**
+ * @var Piwik_TablePartitioning
+ */
+ protected $tableArchiveNumeric;
+ /**
+ * @var Piwik_TablePartitioning
+ */
+ protected $tableArchiveBlob;
+
protected $maxTimestampArchive;
// Attributes that can be accessed by plugins (that is why they are public)
- public $idsite = null;
- public $period = null;
+ public $idsite = null;
+
+ /**
+ * @var Piwik_Period
+ */
+ public $period = null;
+
+ /**
+ * @var Piwik_Site
+ */
public $site = null;
-
+
+
+ // strings
public $strDateStart;
public $strDateEnd;
-
public $logTable;
public $logVisitActionTable;
public $logActionTable;
@@ -60,10 +85,43 @@
public function __construct()
{
$this->debugAlwaysArchive = Zend_Registry::get('config')->Debug->always_archive_data;
-
- }
+ }
+
+
+ /**
+ * Returns the Piwik_ArchiveProcessing_Day or Piwik_ArchiveProcessing_Period object
+ * depending on $name period string
+ *
+ * @param string $name day|week|month|year
+ * @return Piwik_ArchiveProcessing Piwik_ArchiveProcessing_Day|Piwik_ArchiveProcessing_Period
+ */
+ static function factory($name )
+ {
+ switch($name)
+ {
+ case 'day':
+ require_once 'ArchiveProcessing/Day.php';
+ $process = new Piwik_ArchiveProcessing_Day;
+ break;
+
+ case 'week':
+ case 'month':
+ case 'year':
+ require_once 'ArchiveProcessing/Period.php';
+ $process = new Piwik_ArchiveProcessing_Period;
+ break;
+
+ default:
+ throw new Exception("Unknown period specified $name");
+ break;
+ }
+ return $process;
+ }
+
/**
- *
+ * Assign helper variables // init the object
+ *
+ * @return void
*/
protected function loadArchiveProperties()
{
@@ -81,7 +139,9 @@
$this->strDateStart = $this->dateStart->toString();
$this->strDateEnd = $this->dateEnd->toString();
-
+
+ // if the current archive is a DAY and if it's today,
+ // we set this maxTimestampArchive that defines the lifetime value of today's archive
$this->maxTimestampArchive = 0;
if( $this->period->getNumberOfSubperiods() == 0
&& $this->period->toString() == date("Y-m-d")
@@ -91,30 +151,56 @@
}
}
-
+ /**
+ * Returns the name of the numeric table where the archive numeric values are stored
+ *
+ * @return Piwik_TablePartitioning
+ */
public function getTableArchiveNumericName()
{
return $this->tableArchiveNumeric;
}
-
+
+ /**
+ * Returns the name of the blob table where the archive blob values are stored
+ *
+ * @return Piwik_TablePartitioning
+ */
public function getTableArchiveBlobName()
{
return $this->tableArchiveBlob;
}
- // to be used only once
+ /**
+ * Set the period
+ *
+ * @param Piwik_Period $period
+ */
public function setPeriod( Piwik_Period $period )
{
$this->period = $period;
}
-
+ /**
+ * Set the site
+ *
+ * @param Piwik_Site $site
+ */
public function setSite( Piwik_Site $site )
{
$this->site = $site;
}
-
+
+ /**
+ * This method returns the idArchive ; if necessary, it triggers the archiving process.
+ *
+ * If the archive was not processed yet, it will launch the archiving process.
+ * If the current archive needs sub-archives (eg. a month archive needs all the days archive)
+ * it will recursively launch the archiving (using this loadArchive() on the sub-periods)
+ *
+ * @return int The idarchive of the archive
+ */
public function loadArchive()
{
$this->loadArchiveProperties();
@@ -146,7 +232,12 @@
* and computes the archive of the current period.
*/
abstract protected function compute();
-
+
+ /**
+ * Init the object before launching the real archive processing
+ *
+ * @return void
+ */
protected function initCompute()
{
$this->loadNextIdarchive();
@@ -159,10 +250,18 @@
$this->logVisitActionTable = Piwik::prefixTable('log_link_visit_action');
$this->logActionTable = Piwik::prefixTable('log_action');
}
-
+
+ /**
+ * Post processing called at the end of the main archive processing.
+ * Makes sure the new archive is marked as "successful" in the DB
+ *
+ * We also try to delete some stuff from memory but really there is still a lot...
+ *
+ * @return void
+ *
+ */
protected function postCompute()
{
-
// echo "<br>".Piwik_ArchiveProcessing_Record_Manager::getInstance()->toString();
// delete the first done = ERROR
@@ -194,7 +293,11 @@
}
-
+ /**
+ * Returns the idArchive we will use for the current archive
+ *
+ * @return int IdArchive to use when saving the current Archive
+ */
protected function loadNextIdarchive()
{
$db = Zend_Registry::get('db');
@@ -205,7 +308,13 @@
}
$this->idArchive = $id + 1;
- }
+ }
+
+ /**
+ * Inserts a record in the good table (either NUMERIC or BLOB)
+ *
+ * @param unknown_type $record
+ */
protected function insertRecord($record)
{
// table to use to save the data
@@ -234,7 +343,9 @@
}
/**
- * Returns the ID of the archived subperiods.
+ * Returns the ID of the archived subperiods.
+ *
+ * @return array Array of the idArchive of the subperiods
*/
protected function loadSubperiodsArchive()
{
@@ -253,7 +364,13 @@
return $periods;
}
-
+
+ /**
+ * Returns the idArchive if the archive is available in the database.
+ * Returns false if the archive needs to be computed.
+ *
+ * @return int|false
+ */
protected function isArchived()
{
if($this->debugAlwaysArchive)
@@ -295,29 +412,5 @@
return false;
}
}
-
- static function factory($name )
- {
- switch($name)
- {
- case 'day':
- require_once 'ArchiveProcessing/Day.php';
- $process = new Piwik_ArchiveProcessing_Day;
- break;
-
- case 'week':
- case 'month':
- case 'year':
- require_once 'ArchiveProcessing/Period.php';
- $process = new Piwik_ArchiveProcessing_Period;
- break;
-
- default:
- throw new Exception("Unknown period specified $name");
- break;
- }
- return $process;
- }
-
}
Modified: trunk/modules/DataFiles/SearchEngines.php
===================================================================
--- trunk/modules/DataFiles/SearchEngines.php 2008-01-15 01:46:20 UTC (rev 175)
+++ trunk/modules/DataFiles/SearchEngines.php 2008-01-15 04:59:50 UTC (rev 176)
@@ -21,7 +21,7 @@
* in the plugins/Referers/images/SearchEngines directory
* using the format "mainSearchEngineUrl.png". Example: www.google.com.png
*
- * Post your new search engines and logos in the forum, thank you for your help!
+ * Post your new search engines by email at hello at piwik.org ; thanks!
*
*/
if(!isset($GLOBALS['Piwik_SearchEngines'] ))
Modified: trunk/modules/DataTable/Row/DataTableSummary.php
===================================================================
--- trunk/modules/DataTable/Row/DataTableSummary.php 2008-01-15 01:46:20 UTC (rev 175)
+++ trunk/modules/DataTable/Row/DataTableSummary.php 2008-01-15 04:59:50 UTC (rev 176)
@@ -12,7 +12,7 @@
/**
* This class creates a row from a given DataTable.
* The row contains
- * - for each numeric column, the resulting "summary" column is the sum of all the subRows
+ * - for each numeric column, the returned "summary" column is the sum of all the subRows
* - for every other column, it is ignored and will not be in the "summary row"
*
* @see Piwik_DataTable_Row::sumRow() for more information on the algorith
Modified: trunk/plugins/VisitTime.php
===================================================================
--- trunk/plugins/VisitTime.php 2008-01-15 01:46:20 UTC (rev 175)
+++ trunk/plugins/VisitTime.php 2008-01-15 04:59:50 UTC (rev 176)
@@ -90,7 +90,7 @@
{
if($table->getRowFromLabel($i) === false)
{
- $row = $this->archiveProcessing->getEmptyInterestRow($i);
+ $row = $this->archiveProcessing->getNewInterestRowLabeled($i);
$table->addRow( $row );
}
}
More information about the Piwik-svn
mailing list