diff options
author | diosmosis <benaka@piwik.pro> | 2015-05-07 05:23:37 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-06-11 09:42:03 +0300 |
commit | 076ca4093c209eb425787be43ec2b06b49d460d9 (patch) | |
tree | a8cf284288837566de0e3a0b85cda87f2b5fb93e /plugins/UserCountry | |
parent | 58c7f32f42c155226496b3e8bfc83f7639144a0f (diff) |
Use forEach function instead of iterator to loop over logs and replace in usercountry:attribute command. usercountry:attribute tests pass.
Diffstat (limited to 'plugins/UserCountry')
-rw-r--r-- | plugins/UserCountry/Commands/AttributeHistoricalDataWithLocations.php | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/plugins/UserCountry/Commands/AttributeHistoricalDataWithLocations.php b/plugins/UserCountry/Commands/AttributeHistoricalDataWithLocations.php index f8e16cbe7b..774b125471 100644 --- a/plugins/UserCountry/Commands/AttributeHistoricalDataWithLocations.php +++ b/plugins/UserCountry/Commands/AttributeHistoricalDataWithLocations.php @@ -8,6 +8,7 @@ */ namespace Piwik\Plugins\UserCountry\Commands; +use Piwik\DataAccess\RawLogDao\LogsChunk; use Piwik\Plugin\ConsoleCommand; use Piwik\Plugins\UserCountry\VisitorGeolocator; use Piwik\Plugins\UserCountry\LocationProvider; @@ -115,24 +116,19 @@ class AttributeHistoricalDataWithLocations extends ConsoleCommand protected function processSpecifiedLogsInChunks(OutputInterface $output, $from, $to, $segmentLimit) { - // TODO: maybe should rename it, it's not really an iterator but a range at this point. LogRowRange? LazyLogRowRange? - $rawLogIterator = $this->dao->makeLogIterator(array('dateStart' => $from, 'dateEnd' => $to), $segmentLimit); // TODO [ should contain delete by params ] - foreach ($rawLogIterator->getChunks() as $chunk) { - $this->reattributeVisitLogs($output, $chunk->getRows()); - } - /* $visitFieldsToSelect = array_merge(array('idvisit', 'location_ip'), array_keys(VisitorGeolocator::$logVisitFieldsToUpdate)); - $lastId = 0; - do { - $logs = $this->dao->getVisitsWithDatesLimit($from, $to, $visitFieldsToSelect, $lastId, $segmentLimit); - if (!empty($logs)) { - $lastId = $logs[count($logs) - 1]['idvisit']; + $conditions = array( + array('visit_last_action_time', '>=', $from), + array('visit_last_action_time', '<', $to) + ); - $this->reattributeVisitLogs($output, $logs); + $self = $this; + $this->dao->forAllLogs('log_visit', $visitFieldsToSelect, $conditions, $segmentLimit, function ($logs) use ($self, $output) { + if (!empty($logs)) { + $self->reattributeVisitLogs($output, $logs); } - } while (count($logs) == $segmentLimit); - */ + }); } protected function reattributeVisitLogs(OutputInterface $output, $logRows) |