コード例 #1
0
 /**
  * Returns all available archive blob tables
  *
  * @return array
  */
 public static function getAllArchiveBlobTables()
 {
     if (empty(self::$archiveBlobTables)) {
         $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
         self::$archiveBlobTables = array_filter($archiveTables, function ($name) {
             return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE;
         });
         // sort tables so we have them in order of their date
         rsort(self::$archiveBlobTables);
     }
     return (array) self::$archiveBlobTables;
 }
コード例 #2
0
ファイル: 2.10.0-b10.php プロジェクト: piwik/piwik
 public function getMigrations(Updater $updater)
 {
     $migrations = array();
     $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
     $archiveBlobTables = array_filter($archiveTables, function ($name) {
         return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE;
     });
     foreach ($archiveBlobTables as $table) {
         $migrations[] = $this->migration->db->sql("UPDATE {$table} SET name = 'DevicePlugins_plugin' WHERE name = 'UserSettings_plugin'");
     }
     return $migrations;
 }
コード例 #3
0
ファイル: 2.11.0-b4.php プロジェクト: FluentDevelopment/piwik
 public function getMigrationQueries(Updater $updater)
 {
     $sqls = array();
     $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
     $archiveBlobTables = array_filter($archiveTables, function ($name) {
         return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE;
     });
     foreach ($archiveBlobTables as $table) {
         $sqls["UPDATE " . $table . " SET name = 'UserLanguage_language' WHERE name = 'UserSettings_language'"] = false;
     }
     return $sqls;
 }
コード例 #4
0
 public static function getSql()
 {
     $sqls = array();
     $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
     $archiveBlobTables = array_filter($archiveTables, function ($name) {
         return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE;
     });
     foreach ($archiveBlobTables as $table) {
         $sqls["UPDATE " . $table . " SET name = 'DevicePlugins_plugin' WHERE name = 'UserSettings_plugin'"] = false;
     }
     return $sqls;
 }
コード例 #5
0
ファイル: 2.9.0-b7.php プロジェクト: piwik/piwik
 private function addArchivingIdMigrationQueries($sql)
 {
     $tables = ArchiveTableCreator::getTablesArchivesInstalled();
     foreach ($tables as $table) {
         $type = ArchiveTableCreator::getTypeFromTableName($table);
         if ($type === ArchiveTableCreator::NUMERIC_TABLE) {
             $maxId = Db::fetchOne('SELECT MAX(idarchive) FROM ' . $table);
             if (!empty($maxId)) {
                 $maxId = (int) $maxId + 500;
             } else {
                 $maxId = 1;
             }
             $sql[] = $this->migration->db->insert($this->sequenceTable, array('name' => $table, 'value' => $maxId));
         }
     }
     return $sql;
 }
コード例 #6
0
 private static function addArchivingIdMigrationQueries($sql)
 {
     $tables = ArchiveTableCreator::getTablesArchivesInstalled();
     foreach ($tables as $table) {
         $type = ArchiveTableCreator::getTypeFromTableName($table);
         if ($type === ArchiveTableCreator::NUMERIC_TABLE) {
             $maxId = Db::fetchOne('SELECT MAX(idarchive) FROM ' . $table);
             if (!empty($maxId)) {
                 $maxId = (int) $maxId + 500;
             } else {
                 $maxId = 1;
             }
             $query = self::getQueryToCreateSequence($table, $maxId);
             // refs  #6696, ignores  Integrity constraint violation: 1062 Duplicate entry 'piwik_archive_numeric_2010_01' for key 'PRIMARY'
             $sql[$query] = '1062';
         }
     }
     return $sql;
 }
コード例 #7
0
ファイル: Model.php プロジェクト: JoeHorn/piwik
 public function createArchiveTable($tableName, $tableNamePrefix)
 {
     $db = Db::get();
     $sql = DbHelper::getTableCreateSql($tableNamePrefix);
     // replace table name template by real name
     $tableNamePrefix = Common::prefixTable($tableNamePrefix);
     $sql = str_replace($tableNamePrefix, $tableName, $sql);
     try {
         $db->query($sql);
     } catch (Exception $e) {
         // accept mysql error 1050: table already exists, throw otherwise
         if (!$db->isErrNo($e, '1050')) {
             throw $e;
         }
     }
     try {
         if (ArchiveTableCreator::NUMERIC_TABLE === ArchiveTableCreator::getTypeFromTableName($tableName)) {
             $sequence = new Sequence($tableName);
             $sequence->create();
         }
     } catch (Exception $e) {
     }
 }
コード例 #8
0
 /**
  * @param $idSites
  * @param $period string
  * @param $datesByMonth array
  * @throws \Exception
  */
 private function markArchivesInvalidatedFor($idSites, $period, $datesByMonth)
 {
     $invalidateForPeriodId = $this->getPeriodId($period);
     // In each table, invalidate day/week/month/year containing this date
     $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
     $archiveNumericTables = array_filter($archiveTables, function ($name) {
         return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::NUMERIC_TABLE;
     });
     foreach ($archiveNumericTables as $table) {
         // Extract Y_m from table name
         $suffix = ArchiveTableCreator::getDateFromTableName($table);
         if (!isset($datesByMonth[$suffix])) {
             continue;
         }
         // Dates which are to be deleted from this table
         $datesToDelete = $datesByMonth[$suffix];
         self::getModel()->updateArchiveAsInvalidated($table, $idSites, $invalidateForPeriodId, $datesToDelete);
     }
 }
コード例 #9
0
 /**
  * Utility function that finds every archive table whose reports are considered
  * old.
  *
  * @return array An array of two arrays. The first holds the numeric archive table
  *               names, and the second holds the blob archive table names.
  */
 private function getArchiveTablesToPurge()
 {
     // get month for which reports as old or older than, should be deleted
     // reports whose creation date <= this month will be deleted
     // (NOTE: we ignore how far we are in the current month)
     $toRemoveDate = Date::factory('today')->subMonth(1 + $this->deleteReportsOlderThan);
     // find all archive tables that are older than N months
     $oldNumericTables = array();
     $oldBlobTables = array();
     foreach (DbHelper::getTablesInstalled() as $table) {
         $type = ArchiveTableCreator::getTypeFromTableName($table);
         if ($type === false) {
             continue;
         }
         $date = ArchiveTableCreator::getDateFromTableName($table);
         list($year, $month) = explode('_', $date);
         if (self::shouldReportBePurged($year, $month, $toRemoveDate)) {
             if ($type == ArchiveTableCreator::NUMERIC_TABLE) {
                 $oldNumericTables[] = $table;
             } else {
                 $oldBlobTables[] = $table;
             }
         }
     }
     return array($oldNumericTables, $oldBlobTables);
 }