[Piwik-svn] r384 - in trunk/modules: . ArchiveProcessing
svnmaster at piwik.org
svnmaster at piwik.org
Tue Mar 18 11:28:32 CET 2008
Author: matt
Date: 2008-03-18 11:28:25 +0100 (Tue, 18 Mar 2008)
New Revision: 384
Modified:
trunk/modules/ArchiveProcessing.php
trunk/modules/ArchiveProcessing/Day.php
trunk/modules/ArchiveProcessing/Period.php
Log:
- fix #85 huge disk space saving :)
Modified: trunk/modules/ArchiveProcessing/Day.php
===================================================================
--- trunk/modules/ArchiveProcessing/Day.php 2008-03-17 16:09:00 UTC (rev 383)
+++ trunk/modules/ArchiveProcessing/Day.php 2008-03-18 10:28:25 UTC (rev 384)
@@ -68,6 +68,30 @@
Piwik_PostEvent('ArchiveProcessing_Day.compute', $this);
}
+
+ /**
+ * Called at the end of the archiving process
+ *
+ */
+ protected function postCompute()
+ {
+ parent::postCompute();
+
+ // we delete out of date records
+ // = archives that for day N computed on day N (means they are only partial)
+ $blobTable = $this->tableArchiveBlob->getTableName();
+ $numericTable = $this->tableArchiveNumeric->getTableName();
+
+ $query = " DELETE
+ FROM %s
+ WHERE period = ?
+ AND date1 = DATE(ts_archived)
+ AND DATE(ts_archived) <> CURRENT_DATE()
+ ";
+
+ Zend_Registry::get('db')->query(sprintf($query, $blobTable), $this->periodId);
+ Zend_Registry::get('db')->query(sprintf($query, $numericTable), $this->periodId);
+ }
/**
* Helper function that returns a DataTable containing the $select fields / value pairs.
Modified: trunk/modules/ArchiveProcessing/Period.php
===================================================================
--- trunk/modules/ArchiveProcessing/Period.php 2008-03-17 16:09:00 UTC (rev 383)
+++ trunk/modules/ArchiveProcessing/Period.php 2008-03-18 10:28:25 UTC (rev 384)
@@ -21,11 +21,6 @@
*/
class Piwik_ArchiveProcessing_Period extends Piwik_ArchiveProcessing
{
- function __construct()
- {
- parent::__construct();
- }
-
/**
* Sums all values for the given field names $aNames over the period
* See @archiveNumericValuesGeneral for more information
@@ -192,7 +187,8 @@
}
/**
- * Main method to process logs for a period. The only logic done here is computing the number of visits, actions, etc.
+ * Main method to process logs for a period.
+ * The only logic done here is computing the number of visits, actions, etc.
*
* All the other reports are computed inside plugins listening to the event 'ArchiveProcessing_Period.compute'.
* See some of the plugins for an example.
@@ -222,4 +218,30 @@
Piwik_PostEvent('ArchiveProcessing_Period.compute', $this);
}
+
+ /**
+ * Called at the end of the archiving process
+ *
+ */
+ protected function postCompute()
+ {
+ parent::postCompute();
+
+ // we delete records that are now out of date
+ // in the case of a period we delete archives that were archived before the end of the period
+ // and only if they are at least 1 day old (so we don't delete archives computed today that may be stil valid)
+ $blobTable = $this->tableArchiveBlob->getTableName();
+ $numericTable = $this->tableArchiveNumeric->getTableName();
+
+ $query = " DELETE
+ FROM %s
+ WHERE period > ?
+ AND DATE(ts_archived) <= date2
+ AND date(ts_archived) < date_sub(CURRENT_DATE(), INTERVAL 1 DAY)
+ ";
+
+ Zend_Registry::get('db')->query(sprintf($query, $blobTable), Piwik::$idPeriods['day']);
+ Zend_Registry::get('db')->query(sprintf($query, $numericTable), Piwik::$idPeriods['day']);
+ }
+
}
Modified: trunk/modules/ArchiveProcessing.php
===================================================================
--- trunk/modules/ArchiveProcessing.php 2008-03-17 16:09:00 UTC (rev 383)
+++ trunk/modules/ArchiveProcessing.php 2008-03-18 10:28:25 UTC (rev 384)
@@ -317,6 +317,7 @@
// we delete all tables from the table register
Piwik_ArchiveProcessing_Record_Manager::getInstance()->deleteAll();
+
}
/**
More information about the Piwik-svn
mailing list