diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2016-07-13 06:11:06 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2016-07-13 06:11:06 +0300 |
commit | dad0dae15cd8b62dbc91125e2d0e4078909aab73 (patch) | |
tree | 3f2124ca86630f9eec7b8d339671b99d8e33a8d4 /plugins | |
parent | 0a7197f54149b9764792bc7b50f208f55993f0b9 (diff) |
Improved join generation for segments (#10264)
* better join generation for segments
* do not update visit if there are no values to be updated
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/CoreHome/Tracker/LogTable/Action.php | 30 | ||||
-rw-r--r-- | plugins/CoreHome/Tracker/LogTable/Conversion.php | 24 | ||||
-rw-r--r-- | plugins/CoreHome/Tracker/LogTable/ConversionItem.php | 25 | ||||
-rw-r--r-- | plugins/CoreHome/Tracker/LogTable/LinkVisitAction.php | 29 | ||||
-rw-r--r-- | plugins/CoreHome/Tracker/LogTable/Visit.php | 30 | ||||
-rw-r--r-- | plugins/SegmentEditor/SegmentQueryDecorator.php | 4 | ||||
-rw-r--r-- | plugins/SegmentEditor/tests/Unit/SegmentQueryDecoratorTest.php | 5 |
7 files changed, 145 insertions, 2 deletions
diff --git a/plugins/CoreHome/Tracker/LogTable/Action.php b/plugins/CoreHome/Tracker/LogTable/Action.php new file mode 100644 index 0000000000..fdb69e5ec6 --- /dev/null +++ b/plugins/CoreHome/Tracker/LogTable/Action.php @@ -0,0 +1,30 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\CoreHome\Tracker\LogTable; + +use Piwik\Tracker\LogTable; + +class Action extends LogTable +{ + public function getName() + { + return 'log_action'; + } + + public function getColumnToJoinOnIdAction() + { + return 'idaction'; + } + + public function getLinkTableToBeAbleToJoinOnVisit() + { + return 'log_link_visit_action'; + } + +} diff --git a/plugins/CoreHome/Tracker/LogTable/Conversion.php b/plugins/CoreHome/Tracker/LogTable/Conversion.php new file mode 100644 index 0000000000..e920864088 --- /dev/null +++ b/plugins/CoreHome/Tracker/LogTable/Conversion.php @@ -0,0 +1,24 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\CoreHome\Tracker\LogTable; + +use Piwik\Tracker\LogTable; + +class Conversion extends LogTable +{ + public function getName() + { + return 'log_conversion'; + } + + public function getColumnToJoinOnIdVisit() + { + return 'idvisit'; + } +}
\ No newline at end of file diff --git a/plugins/CoreHome/Tracker/LogTable/ConversionItem.php b/plugins/CoreHome/Tracker/LogTable/ConversionItem.php new file mode 100644 index 0000000000..566841b4fa --- /dev/null +++ b/plugins/CoreHome/Tracker/LogTable/ConversionItem.php @@ -0,0 +1,25 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\CoreHome\Tracker\LogTable; + +use Piwik\Tracker\LogTable; + +class ConversionItem extends LogTable +{ + public function getName() + { + return 'log_conversion_item'; + } + + public function getColumnToJoinOnIdVisit() + { + return 'idvisit'; + } + +} diff --git a/plugins/CoreHome/Tracker/LogTable/LinkVisitAction.php b/plugins/CoreHome/Tracker/LogTable/LinkVisitAction.php new file mode 100644 index 0000000000..cb102d407c --- /dev/null +++ b/plugins/CoreHome/Tracker/LogTable/LinkVisitAction.php @@ -0,0 +1,29 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\CoreHome\Tracker\LogTable; + +use Piwik\Tracker\LogTable; + +class LinkVisitAction extends LogTable +{ + public function getName() + { + return 'log_link_visit_action'; + } + + public function getColumnToJoinOnIdAction() + { + return 'idaction_url'; + } + + public function getColumnToJoinOnIdVisit() + { + return 'idvisit'; + } +} diff --git a/plugins/CoreHome/Tracker/LogTable/Visit.php b/plugins/CoreHome/Tracker/LogTable/Visit.php new file mode 100644 index 0000000000..f403c37697 --- /dev/null +++ b/plugins/CoreHome/Tracker/LogTable/Visit.php @@ -0,0 +1,30 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\CoreHome\Tracker\LogTable; + +use Piwik\Tracker\LogTable; + +class Visit extends LogTable +{ + public function getName() + { + return 'log_visit'; + } + + public function getColumnToJoinOnIdVisit() + { + return 'idvisit'; + } + + public function shouldJoinWithSubSelect() + { + return true; + } + +}
\ No newline at end of file diff --git a/plugins/SegmentEditor/SegmentQueryDecorator.php b/plugins/SegmentEditor/SegmentQueryDecorator.php index d501f6f9b1..130cc59bd5 100644 --- a/plugins/SegmentEditor/SegmentQueryDecorator.php +++ b/plugins/SegmentEditor/SegmentQueryDecorator.php @@ -9,6 +9,7 @@ namespace Piwik\Plugins\SegmentEditor; use Piwik\DataAccess\LogQueryBuilder; +use Piwik\Plugin\LogTablesProvider; use Piwik\Plugins\SegmentEditor\Services\StoredSegmentService; use Piwik\Segment\SegmentExpression; use Piwik\SettingsServer; @@ -26,9 +27,10 @@ class SegmentQueryDecorator extends LogQueryBuilder */ private $storedSegmentService; - public function __construct(StoredSegmentService $storedSegmentService) + public function __construct(StoredSegmentService $storedSegmentService, LogTablesProvider $logTablesProvider) { $this->storedSegmentService = $storedSegmentService; + parent::__construct($logTablesProvider); } public function getSelectQueryString(SegmentExpression $segmentExpression, $select, $from, $where, $bind, $groupBy, diff --git a/plugins/SegmentEditor/tests/Unit/SegmentQueryDecoratorTest.php b/plugins/SegmentEditor/tests/Unit/SegmentQueryDecoratorTest.php index 6ecad82f2f..7e38188966 100644 --- a/plugins/SegmentEditor/tests/Unit/SegmentQueryDecoratorTest.php +++ b/plugins/SegmentEditor/tests/Unit/SegmentQueryDecoratorTest.php @@ -11,6 +11,7 @@ namespace Piwik\Plugins\SegmentEditor\tests\Unit; use Piwik\Plugins\SegmentEditor\SegmentQueryDecorator; use Piwik\Plugins\SegmentEditor\Services\StoredSegmentService; use Piwik\Segment\SegmentExpression; +use Piwik\Tests\Framework\Mock\Plugin\LogTablesProvider; /** * @group SegmentEditor @@ -36,7 +37,8 @@ class SegmentQueryDecoratorTest extends \PHPUnit_Framework_TestCase /** @var StoredSegmentService $service */ $service = $this->getMockSegmentEditorService(); - $this->decorator = new SegmentQueryDecorator($service); + $logTables = new LogTablesProvider(); + $this->decorator = new SegmentQueryDecorator($service, $logTables); } public function test_getSelectQueryString_DoesNotDecorateSql_WhenNoSegmentUsed() @@ -86,4 +88,5 @@ class SegmentQueryDecoratorTest extends \PHPUnit_Framework_TestCase $mock->expects($this->any())->method('getAllSegmentsAndIgnoreVisibility')->willReturn(self::$storedSegments); return $mock; } + } |