diff options
author | diosmosis <benaka@piwik.pro> | 2015-05-13 14:34:16 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-06-11 09:42:05 +0300 |
commit | 92e1482213ff31bede001fdc994048a8ae945fe5 (patch) | |
tree | ef9a23bc166ff05b2f01341d5a4bfb10cc505b9c /plugins/UserCountry | |
parent | b187a823c1ea6cb0a6e0c0dc5c82eaadbff3120e (diff) |
Document VisitorGeolocator::reattributeVisits, rename LogInserter to LogHelper and add quick class docs to LogHelper.
Diffstat (limited to 'plugins/UserCountry')
-rw-r--r-- | plugins/UserCountry/VisitorGeolocator.php | 21 | ||||
-rw-r--r-- | plugins/UserCountry/tests/Integration/VisitorGeolocatorTest.php | 6 |
2 files changed, 14 insertions, 13 deletions
diff --git a/plugins/UserCountry/VisitorGeolocator.php b/plugins/UserCountry/VisitorGeolocator.php index 4ef710b77d..1c517075a1 100644 --- a/plugins/UserCountry/VisitorGeolocator.php +++ b/plugins/UserCountry/VisitorGeolocator.php @@ -234,15 +234,16 @@ class VisitorGeolocator } /** - * TODO + * Re-geolocate visits within a date range for a specified site (if any). * - * @param $from - * @param $to - * @param null $idSite - * @param int $segmentLimit - * @param callable $onLogProcessed + * @param string $from A datetime string to treat as the lower bound. Visits newer than this date are processed. + * @param string $to A datetime string to treat as the upper bound. Visits older than this date are processed. + * @param int|null $idSite If supplied, only visits for this site are re-attributed. + * @param int $iterationStep The number of visits to re-attribute at the same time. + * @param callable|null $onLogProcessed If supplied, this callback is called after every row is processed. + * The processed visit and the updated values are passed to the callback. */ - public function reattributeVisitLogs($from, $to, $idSite = null, $segmentLimit = 1000, $onLogProcessed = null) + public function reattributeVisitLogs($from, $to, $idSite = null, $iterationStep = 1000, $onLogProcessed = null) { $visitFieldsToSelect = array_merge(array('idvisit', 'location_ip'), array_keys(VisitorGeolocator::$logVisitFieldsToUpdate)); @@ -256,12 +257,12 @@ class VisitorGeolocator } $self = $this; - $this->dao->forAllLogs('log_visit', $visitFieldsToSelect, $conditions, $segmentLimit, function ($logs) use ($self, $onLogProcessed) { + $this->dao->forAllLogs('log_visit', $visitFieldsToSelect, $conditions, $iterationStep, function ($logs) use ($self, $onLogProcessed) { foreach ($logs as $row) { - $self->attributeExistingVisit($row); + $updatedValues = $self->attributeExistingVisit($row); if (!empty($onLogProcessed)) { - $onLogProcessed($row); + $onLogProcessed($row, $updatedValues); } } }); diff --git a/plugins/UserCountry/tests/Integration/VisitorGeolocatorTest.php b/plugins/UserCountry/tests/Integration/VisitorGeolocatorTest.php index c07e7a966b..ef1be64b1a 100644 --- a/plugins/UserCountry/tests/Integration/VisitorGeolocatorTest.php +++ b/plugins/UserCountry/tests/Integration/VisitorGeolocatorTest.php @@ -15,7 +15,7 @@ use Piwik\Network\IPUtils; use Piwik\Plugins\UserCountry\VisitorGeolocator; use Piwik\Plugins\UserCountry\LocationProvider; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; -use Piwik\Tests\Framework\TestDataHelper\LogInserter; +use Piwik\Tests\Framework\TestDataHelper\LogHelper; use Piwik\Tracker\Cache; use Piwik\Tracker\Visit; use Piwik\Tests\Framework\Mock\LocationProvider as MockLocationProvider; @@ -30,7 +30,7 @@ class VisitorGeolocatorTest extends IntegrationTestCase const TEST_IP = '1.2.3.4'; /** - * @var LogInserter + * @var LogHelper */ private $logInserter; @@ -38,7 +38,7 @@ class VisitorGeolocatorTest extends IntegrationTestCase { parent::setUp(); - $this->logInserter = new LogInserter(); + $this->logInserter = new LogHelper(); } public function test_getLocation_shouldReturnLocationForProvider_IfLocationIsSetForCurrentProvider() |