Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbenakamoorthi <benaka.moorthi@gmail.com>2012-07-19 08:45:46 +0400
committerbenakamoorthi <benaka.moorthi@gmail.com>2012-07-19 08:45:46 +0400
commitd77ec9e889e2a6d8f9969832bfda3aa044c50bc1 (patch)
tree8fb484f95d2fdffea8f4393dcfdc8936f1377156 /plugins/PrivacyManager/LogDataPurger.php
parent41dc6a5d7c26659711232ba4eb0db5717502c1ab (diff)
Refs #3196, forgot to use segmented query strategy w/ log_action purging.
git-svn-id: http://dev.piwik.org/svn/trunk@6519 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'plugins/PrivacyManager/LogDataPurger.php')
-rwxr-xr-xplugins/PrivacyManager/LogDataPurger.php39
1 files changed, 32 insertions, 7 deletions
diff --git a/plugins/PrivacyManager/LogDataPurger.php b/plugins/PrivacyManager/LogDataPurger.php
index 3bcadde1ff..cd3503b224 100755
--- a/plugins/PrivacyManager/LogDataPurger.php
+++ b/plugins/PrivacyManager/LogDataPurger.php
@@ -133,8 +133,8 @@ class Piwik_PrivacyManager_LogDataPurger
{
$this->createTempTable();
- // get current max visit ID in log tables w/ idaction references.
- $maxIds = $this->getMaxVisitIdsInLogTables();
+ // get current max ID in log tables w/ idaction references.
+ $maxIds = $this->getMaxIdsInLogTables();
// do large insert (inserting everything before maxIds) w/o locking tables...
$this->insertActionsToKeep($maxIds, $deleteOlderThanMax = true);
@@ -192,14 +192,16 @@ class Piwik_PrivacyManager_LogDataPurger
Piwik_Query($sql);
}
- private function getMaxVisitIdsInLogTables()
+ private function getMaxIdsInLogTables()
{
$tables = array('log_conversion', 'log_link_visit_action', 'log_visit', 'log_conversion_item');
+ $idColumns = $this->getTableIdColumns();
$result = array();
foreach ($tables as $table)
{
- $result[$table] = Piwik_FetchOne("SELECT MAX(idvisit) FROM ".Piwik_Common::prefixTable($table));
+ $idCol = $idColumns[$table];
+ $result[$table] = Piwik_FetchOne("SELECT MAX($idCol) FROM ".Piwik_Common::prefixTable($table));
}
return $result;
@@ -208,16 +210,29 @@ class Piwik_PrivacyManager_LogDataPurger
private function insertActionsToKeep( $maxIds, $olderThan = true )
{
$tempTableName = Piwik_Common::prefixTable(self::TEMP_TABLE_NAME);
- $idvisitCondition = $olderThan ? "idvisit <= ?" : "idvisit > ?";
+ $idColumns = $this->getTableIdColumns();
foreach ($this->getIdActionColumns() as $table => $columns)
{
+ $idCol = $idColumns[$table];
+
foreach ($columns as $col)
{
- $select = "SELECT $col FROM ".Piwik_Common::prefixTable($table)." WHERE $idvisitCondition";
+ $select = "SELECT $col FROM ".Piwik_Common::prefixTable($table)." WHERE $idCol >= ? AND $idCol < ?";
$sql = "INSERT IGNORE INTO $tempTableName $select";
- Piwik_Query($sql, array($maxIds[$table]));
+ if ($olderThan)
+ {
+ $start = 0;
+ $finish = $maxIds[$table];
+ }
+ else
+ {
+ $start = $maxIds[$table];
+ $finish = Piwik_FetchOne("SELECT MAX($idCol) FROM ".Piwik_Common::prefixTable($table));
+ }
+
+ Piwik_SegmentedQuery($sql, $start, $finish, self::$selectSegmentSize);
}
}
@@ -285,6 +300,16 @@ class Piwik_PrivacyManager_LogDataPurger
);
}
+ private function getTableIdColumns()
+ {
+ return array(
+ 'log_link_visit_action' => 'idlink_va',
+ 'log_conversion' => 'idvisit',
+ 'log_visit' => 'idvisit',
+ 'log_conversion_item' => 'idvisit'
+ );
+ }
+
// let's hardcode, since these are not dynamically created tables
public static function getDeleteTableLogTables()
{