当前位置: 首页>>代码示例>>PHP>>正文


PHP ArchiveProcessor\Rules类代码示例

本文整理汇总了PHP中Piwik\ArchiveProcessor\Rules的典型用法代码示例。如果您正苦于以下问题:PHP Rules类的具体用法?PHP Rules怎么用?PHP Rules使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Rules类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_purgeOutdatedArchives_Purges_WhenBrowserArchivingEnabled_AndCronArchiveTriggerPresent

 public function test_purgeOutdatedArchives_Purges_WhenBrowserArchivingEnabled_AndCronArchiveTriggerPresent()
 {
     Rules::setBrowserTriggerArchiving(false);
     $_GET['trigger'] = 'archivephp';
     $wasPurged = $this->tasks->purgeOutdatedArchives();
     $this->assertTrue($wasPurged);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:7,代码来源:TasksTest.php

示例2: testArchivingProcess

 /**
  * @group        Benchmarks
  */
 public function testArchivingProcess()
 {
     if ($this->archivingLaunched) {
         echo "NOTE: Had to archive data, memory results will not be accurate. Run again for better results.";
     }
     Rules::$archivingDisabledByTests = true;
     APIMultiSites::getInstance()->getAll(self::$fixture->period, self::$fixture->date);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:11,代码来源:MultiSitesBenchmark.php

示例3: setArchiveSettings

 /**
  * @internal
  */
 public function setArchiveSettings($enableBrowserTriggerArchiving, $todayArchiveTimeToLive)
 {
     Piwik::checkUserHasSuperUserAccess();
     if (!Controller::isGeneralSettingsAdminEnabled()) {
         throw new Exception('General settings admin is ont enabled');
     }
     Rules::setBrowserTriggerArchiving((bool) $enableBrowserTriggerArchiving);
     Rules::setTodayArchiveTimeToLive($todayArchiveTimeToLive);
     return true;
 }
开发者ID:piwik,项目名称:piwik,代码行数:13,代码来源:API.php

示例4: testArchivingProcess

 /**
  * @group        Benchmarks
  */
 public function testArchivingProcess()
 {
     if ($this->archivingLaunched) {
         echo "NOTE: Had to archive data, memory results will not be accurate. Run again for better results.";
     }
     Rules::$archivingDisabledByTests = true;
     $period = Period\Factory::build(self::$fixture->period, Date::factory(self::$fixture->date));
     $dateRange = $period->getDateStart() . ',' . $period->getDateEnd();
     API::getInstance()->get(self::$fixture->idSite, 'day', $dateRange);
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:13,代码来源:ArchiveQueryBenchmark.php

示例5: __construct

 public function __construct(ArchiveProcessor\Parameters $params, $isArchiveTemporary)
 {
     $this->idArchive = false;
     $this->idSite = $params->getSite()->getId();
     $this->segment = $params->getSegment();
     $this->period = $params->getPeriod();
     $this->doneFlag = Rules::getDoneStringFlagFor($this->segment, $this->period->getLabel(), $params->getRequestedPlugin());
     $this->isArchiveTemporary = $isArchiveTemporary;
     $this->dateStart = $this->period->getDateStart();
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:10,代码来源:ArchiveWriter.php

示例6: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // Temporarily disable the purge of old archives so that getNumeric('nb_visits')
     // in _addReportData does not trigger the data purge of data we've just imported
     Rules::$purgeDisabledByTests = true;
     self::_addLogData();
     self::_addReportData();
     Rules::$purgeDisabledByTests = false;
     self::$dbData = self::getDbTablesWithData();
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:11,代码来源:PrivacyManagerTest.php

示例7: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // Temporarily disable the purge of old archives so that getNumeric('nb_visits')
     // in _addReportData does not trigger the data purge of data we've just imported
     \Piwik\ArchiveProcessor\Rules::disablePurgeOutdatedArchives();
     self::_addLogData();
     self::_addReportData();
     \Piwik\ArchiveProcessor\Rules::enablePurgeOutdatedArchives();
     self::$dbData = self::getDbTablesWithData();
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:11,代码来源:PrivacyManagerTest.php

示例8: purgeOutdatedArchives

 public static function purgeOutdatedArchives(Date $dateStart)
 {
     $purgeArchivesOlderThan = Rules::shouldPurgeOutdatedArchives($dateStart);
     if (!$purgeArchivesOlderThan) {
         return;
     }
     $idArchivesToDelete = self::getTemporaryArchiveIdsOlderThan($dateStart, $purgeArchivesOlderThan);
     if (!empty($idArchivesToDelete)) {
         self::deleteArchiveIds($dateStart, $idArchivesToDelete);
     }
     self::deleteArchivesWithPeriodRange($dateStart);
     Log::debug("Purging temporary archives: done [ purged archives older than %s in %s ] [Deleted IDs: %s]", $purgeArchivesOlderThan, $dateStart->toString("Y-m"), implode(',', $idArchivesToDelete));
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:13,代码来源:ArchivePurger.php

示例9: setUp

 public function setUp()
 {
     // drop all tables
     Db::dropAllTables();
     // download data dump if url supplied
     if (is_file($this->dumpUrl)) {
         $dumpPath = $this->dumpUrl;
     } else {
         $dumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql.gz';
         $bufferSize = 1024 * 1024;
         $dump = fopen($this->dumpUrl, 'rb');
         $outfile = fopen($dumpPath, 'wb');
         $bytesRead = 0;
         while (!feof($dump)) {
             fwrite($outfile, fread($dump, $bufferSize), $bufferSize);
             $bytesRead += $bufferSize;
         }
         fclose($dump);
         fclose($outfile);
         if ($bytesRead <= 40 * 1024 * 1024) {
             // sanity check
             throw new Exception("Could not download sql dump!");
         }
     }
     // unzip the dump
     if (substr($dumpPath, -3) === ".gz") {
         $deflatedDumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql';
         // TODO: should depend on name of URL
         exec("gunzip -c \"" . $dumpPath . "\" > \"{$deflatedDumpPath}\"", $output, $return);
         if ($return !== 0) {
             throw new Exception("gunzip failed: " . implode("\n", $output));
         }
     } else {
         $deflatedDumpPath = $dumpPath;
     }
     // load the data into the correct database
     $user = Config::getInstance()->database['username'];
     $password = Config::getInstance()->database['password'];
     Config::getInstance()->database['tables_prefix'] = $this->tablesPrefix;
     $cmd = "mysql -u \"{$user}\" \"--password={$password}\" {$this->dbName} < \"" . $deflatedDumpPath . "\" 2>&1";
     exec($cmd, $output, $return);
     if ($return !== 0) {
         throw new Exception("Failed to load sql dump: " . implode("\n", $output));
     }
     // make sure archiving will be called
     Rules::setBrowserTriggerArchiving(true);
     // reload access
     Piwik::setUserHasSuperUserAccess();
     $this->getTestEnvironment()->configOverride = array('database' => array('tables_prefix' => $this->tablesPrefix));
     $this->getTestEnvironment()->save();
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:51,代码来源:SqlDump.php

示例10: setUp

 public function setUp()
 {
     // drop all tables
     Db::dropAllTables();
     // download data dump if url supplied
     if (is_file($this->dumpUrl)) {
         $dumpPath = $this->dumpUrl;
     } else {
         $dumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql.gz';
         $bytesRead = $this->downloadDumpInPath($dumpPath);
         // sanity check
         if ($bytesRead <= 40 * 1024 * 1024) {
             $str = "Could not download sql dump! You can manually download %s into %s";
             throw new Exception(sprintf($str, $this->dumpUrl, $dumpPath));
         }
     }
     // unzip the dump
     if (substr($dumpPath, -3) === ".gz") {
         $deflatedDumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql';
         // TODO: should depend on name of URL
         exec("gunzip -c \"" . $dumpPath . "\" > \"{$deflatedDumpPath}\"", $output, $return);
         if ($return !== 0) {
             throw new Exception("gunzip failed: " . implode("\n", $output));
         }
     } else {
         $deflatedDumpPath = $dumpPath;
     }
     // load the data into the correct database
     $user = Config::getInstance()->database['username'];
     $password = Config::getInstance()->database['password'];
     $host = Config::getInstance()->database['host'];
     Config::getInstance()->database['tables_prefix'] = $this->tablesPrefix;
     $cmd = "mysql -h \"{$host}\" -u \"{$user}\" \"--password={$password}\" {$this->dbName} < \"" . $deflatedDumpPath . "\" 2>&1";
     exec($cmd, $output, $return);
     if ($return !== 0) {
         throw new Exception("Failed to load sql dump: " . implode("\n", $output));
     }
     // make sure archiving will be called
     Rules::setBrowserTriggerArchiving(true);
     // reload access
     Access::getInstance()->reloadAccess();
     $testVars = new TestingEnvironmentVariables();
     $testVars->configOverride = array('database' => array('tables_prefix' => $this->tablesPrefix));
     $testVars->save();
 }
开发者ID:diosmosis,项目名称:piwik,代码行数:45,代码来源:SqlDump.php

示例11: __construct

 /**
  * Constructor.
  */
 public function __construct($idSite = false)
 {
     parent::__construct();
     $this->jsClass = "SegmentSelectorControl";
     $this->cssIdentifier = "segmentEditorPanel";
     $this->cssClass = "piwikTopControl borderedControl piwikSelector";
     $this->idSite = $idSite ?: Common::getRequestVar('idSite', false, 'int');
     $this->selectedSegment = Common::getRequestVar('segment', false, 'string');
     $formatter = StaticContainer::get('Piwik\\Plugins\\SegmentEditor\\SegmentFormatter');
     $this->segmentDescription = $formatter->getHumanReadable(Request::getRawSegmentFromRequest(), $this->idSite);
     $this->isAddingSegmentsForAllWebsitesEnabled = SegmentEditor::isAddingSegmentsForAllWebsitesEnabled();
     $segments = APIMetadata::getInstance()->getSegmentsMetadata($this->idSite);
     $visitTitle = Piwik::translate('General_Visit');
     $segmentsByCategory = array();
     foreach ($segments as $segment) {
         if ($segment['category'] == $visitTitle && ($segment['type'] == 'metric' && $segment['segment'] != 'visitIp')) {
             $metricsLabel = Piwik::translate('General_Metrics');
             $metricsLabel[0] = Common::mb_strtolower($metricsLabel[0]);
             $segment['category'] .= ' (' . $metricsLabel . ')';
         }
         $segmentsByCategory[$segment['category']][] = $segment;
     }
     $this->createRealTimeSegmentsIsEnabled = Config::getInstance()->General['enable_create_realtime_segments'];
     $this->segmentsByCategory = $segmentsByCategory;
     $this->nameOfCurrentSegment = '';
     $this->isSegmentNotAppliedBecauseBrowserArchivingIsDisabled = 0;
     $this->availableSegments = API::getInstance()->getAll($this->idSite);
     foreach ($this->availableSegments as &$savedSegment) {
         $savedSegment['name'] = Common::sanitizeInputValue($savedSegment['name']);
         if (!empty($this->selectedSegment) && $this->selectedSegment == $savedSegment['definition']) {
             $this->nameOfCurrentSegment = $savedSegment['name'];
             $this->isSegmentNotAppliedBecauseBrowserArchivingIsDisabled = $this->wouldApplySegment($savedSegment) ? 0 : 1;
         }
     }
     $this->authorizedToCreateSegments = SegmentEditorAPI::getInstance()->isUserCanAddNewSegment($this->idSite);
     $this->isUserAnonymous = Piwik::isUserIsAnonymous();
     $this->segmentTranslations = $this->getTranslations();
     $this->segmentProcessedOnRequest = Rules::isBrowserArchivingAvailableForSegments();
     $this->hideSegmentDefinitionChangeMessage = UsersManagerAPI::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), 'hideSegmentDefinitionChangeMessage');
 }
开发者ID:diosmosis,项目名称:piwik,代码行数:43,代码来源:SegmentSelectorControl.php

示例12: getDoneStringForPlugin

 /**
  * Returns the done string flag for a plugin using this instance's segment & periods.
  * @param string $plugin
  * @return string
  */
 private function getDoneStringForPlugin($plugin)
 {
     return Rules::getDoneStringFlagFor($this->params->getIdSites(), $this->params->getSegment(), $this->getPeriodLabel(), $plugin, $this->params->isSkipAggregationOfSubTables());
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:9,代码来源:Archive.php

示例13: getOldestTemporaryArchiveToKeepThreshold

 /**
  * Returns a timestamp indicating outdated archives older than this timestamp (processed before) can be purged.
  *
  * @return int|bool  Outdated archives older than this timestamp should be purged
  */
 protected function getOldestTemporaryArchiveToKeepThreshold()
 {
     $temporaryArchivingTimeout = Rules::getTodayArchiveTimeToLive();
     if (Rules::isBrowserTriggerEnabled()) {
         // If Browser Archiving is enabled, it is likely there are many more temporary archives
         // We delete more often which is safe, since reports are re-processed on demand
         return Date::factory($this->now - 2 * $temporaryArchivingTimeout)->getDateTime();
     }
     // If cron core:archive command is building the reports, we should keep all temporary reports from today
     return $this->yesterday->getDateTime();
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:16,代码来源:ArchivePurger.php

示例14: getPossibleValues

 /**
  * Returns the SQL condition used to find successfully completed archives that
  * this instance is querying for.
  *
  * @return string
  */
 private static function getPossibleValues()
 {
     $possibleValues = array(ArchiveWriter::DONE_OK, ArchiveWriter::DONE_OK_TEMPORARY);
     if (!Rules::isRequestAuthorizedToArchive()) {
         //If request is not authorized to archive then fetch also invalidated archives
         $possibleValues[] = ArchiveWriter::DONE_INVALIDATED;
     }
     return $possibleValues;
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:15,代码来源:ArchiveSelector.php

示例15: update

 static function update()
 {
     $returningMetrics = array('nb_visits_returning', 'nb_actions_returning', 'max_actions_returning', 'sum_visit_length_returning', 'bounce_count_returning', 'nb_visits_converted_returning', 'nb_uniq_visitors_returning');
     $now = Date::factory('now')->getDatetime();
     $archiveNumericTables = Db::get()->fetchCol("SHOW TABLES LIKE '%archive_numeric%'");
     // for each numeric archive table, copy *_returning metrics to VisitsSummary metrics w/ the appropriate
     // returning visit segment
     foreach ($archiveNumericTables as $table) {
         // get archives w/ *._returning
         $sql = "SELECT idarchive, idsite, period, date1, date2\n                      FROM {$table}\n                     WHERE name IN ('" . implode("','", $returningMetrics) . "')\n                  GROUP BY idarchive";
         $idArchivesWithReturning = Db::fetchAll($sql);
         // get archives for visitssummary returning visitor segment
         $sql = "SELECT idarchive, idsite, period, date1, date2\n                      FROM {$table}\n                     WHERE name = ?\n                  GROUP BY idarchive";
         $visitSummaryReturningSegmentDone = Rules::getDoneFlagArchiveContainsOnePlugin(new Segment(VisitFrequencyApi::RETURNING_VISITOR_SEGMENT, $idSites = array()), 'VisitsSummary');
         $idArchivesWithVisitReturningSegment = Db::fetchAll($sql, array($visitSummaryReturningSegmentDone));
         // collect info for new visitssummary archives have to be created to match archives w/ *._returning
         // metrics
         $missingIdArchives = array();
         $idArchiveMappings = array();
         foreach ($idArchivesWithReturning as $row) {
             $withMetricsIdArchive = $row['idarchive'];
             foreach ($idArchivesWithVisitReturningSegment as $segmentRow) {
                 if ($row['idsite'] == $segmentRow['idsite'] && $row['period'] == $segmentRow['period'] && $row['date1'] == $segmentRow['date1'] && $row['date2'] == $segmentRow['date2']) {
                     $idArchiveMappings[$withMetricsIdArchive] = $segmentRow['idarchive'];
                 }
             }
             if (!isset($idArchiveMappings[$withMetricsIdArchive])) {
                 $missingIdArchives[$withMetricsIdArchive] = $row;
             }
         }
         // if there are missing idarchives, fill out new archive row values
         if (!empty($missingIdArchives)) {
             $newIdArchiveStart = Db::fetchOne("SELECT MAX(idarchive) FROM {$table}") + 1;
             foreach ($missingIdArchives as $withMetricsIdArchive => &$rowToInsert) {
                 $idArchiveMappings[$withMetricsIdArchive] = $newIdArchiveStart;
                 $rowToInsert['idarchive'] = $newIdArchiveStart;
                 $rowToInsert['ts_archived'] = $now;
                 $rowToInsert['name'] = $visitSummaryReturningSegmentDone;
                 $rowToInsert['value'] = ArchiveWriter::DONE_OK;
                 ++$newIdArchiveStart;
             }
             // add missing archives
             try {
                 $params = array();
                 foreach ($missingIdArchives as $missingIdArchive) {
                     $params[] = array_values($missingIdArchive);
                 }
                 BatchInsert::tableInsertBatch($table, array_keys(reset($missingIdArchives)), $params, $throwException = false);
             } catch (\Exception $ex) {
                 Updater::handleQueryError($ex, "<batch insert>", false, __FILE__);
             }
         }
         // update idarchive & name columns in rows with *._returning metrics
         $updateSqlPrefix = "UPDATE {$table}\n                                   SET idarchive = CASE idarchive ";
         $updateSqlSuffix = " END, name = CASE name ";
         foreach ($returningMetrics as $metric) {
             $newMetricName = substr($metric, 0, strlen($metric) - strlen(VisitFrequencyApi::COLUMN_SUFFIX));
             $updateSqlSuffix .= "WHEN '{$metric}' THEN '" . $newMetricName . "' ";
         }
         $updateSqlSuffix .= " END WHERE idarchive IN (%s)\n                                        AND name IN ('" . implode("','", $returningMetrics) . "')";
         // update only 1000 rows at a time so we don't send too large an SQL query to MySQL
         foreach (array_chunk($missingIdArchives, 1000, $preserveKeys = true) as $chunk) {
             $idArchives = array();
             $updateSql = $updateSqlPrefix;
             foreach ($chunk as $withMetricsIdArchive => $row) {
                 $updateSql .= "WHEN {$withMetricsIdArchive} THEN {$row['idarchive']} ";
                 $idArchives[] = $withMetricsIdArchive;
             }
             $updateSql .= sprintf($updateSqlSuffix, implode(',', $idArchives));
             Updater::executeMigrationQuery($updateSql, false, __FILE__);
         }
     }
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:73,代码来源:2.1.1-b11.php


注:本文中的Piwik\ArchiveProcessor\Rules类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。