قرینه از
https://github.com/matomo-org/matomo.git
synced 2025-08-21 22:47:43 +00:00

* Add feature flag and update test to use feature flag
* Add rollup behaviour to CustomDimension SQL query generation
* Fix bugs in SQL statement with rollup
* Resolve SQL query bugs
* Process rolled up values correctly
* Fix PHPCS
* Fix PHPCS
* Update Unit tests for ranking query
* Fix PHPCS
* Update broken tests
* Update expected test files
* Add missing expected files
* Revert "Update expected test files"
This reverts commit e5bdd0f414
.
* Update test to view correct expected files
* Added missing expected files
* fix feature flag detection
* Update ApiTest to remove testSuffix bug
* Update expected test files
* Update UI tests broken by new feature
* Wrap new logic around a check for feature flag
* Update expected test files to fix regression issue
* Add feature flag trigger into test
* Fix UI tests broken by test fixture update
* Revert separate functions for withRollup logic
* Update test suite to include ranking limit test withoutnew feature
* Fix formatting in test
* PHPCS fix
* Update Fixture to use correct dimension
* test fix of regression bug
* test fix to regression bug
* Wrap COALESCE around feature flag
* Remove test case from base ranking query test
* PHPCS fix
* Update expected test file
* Housekeeping
---------
Co-authored-by: Marc Neudert <marc@innocraft.com>
93 خطوط
2.6 KiB
PHP
93 خطوط
2.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Matomo - free/libre analytics platform
|
|
*
|
|
* @link https://matomo.org
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
|
*/
|
|
|
|
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;
|
|
|
|
/**
|
|
* Decorates segment sub-queries in archiving queries w/ the idSegment of the segment, if
|
|
* a stored segment exists.
|
|
*
|
|
* This class is configured for use in SegmentEditor's DI config.
|
|
*/
|
|
class SegmentQueryDecorator extends LogQueryBuilder
|
|
{
|
|
/**
|
|
* @var StoredSegmentService
|
|
*/
|
|
private $storedSegmentService;
|
|
|
|
public function __construct(StoredSegmentService $storedSegmentService, LogTablesProvider $logTablesProvider)
|
|
{
|
|
$this->storedSegmentService = $storedSegmentService;
|
|
parent::__construct($logTablesProvider);
|
|
}
|
|
|
|
public function getSelectQueryString(
|
|
SegmentExpression $segmentExpression,
|
|
$select,
|
|
$from,
|
|
$where,
|
|
$bind,
|
|
$groupBy,
|
|
$orderBy,
|
|
$limit,
|
|
bool $withRollup = false
|
|
) {
|
|
$result = parent::getSelectQueryString(
|
|
$segmentExpression,
|
|
$select,
|
|
$from,
|
|
$where,
|
|
$bind,
|
|
$groupBy,
|
|
$orderBy,
|
|
$limit,
|
|
$withRollup
|
|
);
|
|
|
|
$prefixParts = array();
|
|
|
|
if (SettingsServer::isArchivePhpTriggered()) {
|
|
$prefixParts[] = 'trigger = CronArchive';
|
|
}
|
|
|
|
$idSegments = $this->getSegmentIdOfExpression($segmentExpression);
|
|
if (!empty($idSegments)) {
|
|
$prefixParts[] = "idSegments = [" . implode(', ', $idSegments) . "]";
|
|
}
|
|
|
|
$select = 'SELECT';
|
|
if (!empty($prefixParts) && 0 === strpos(trim($result['sql']), $select)) {
|
|
$result['sql'] = trim($result['sql']);
|
|
$result['sql'] = 'SELECT /* ' . implode(', ', $prefixParts) . ' */' . substr($result['sql'], strlen($select));
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
private function getSegmentIdOfExpression(SegmentExpression $segmentExpression)
|
|
{
|
|
$allSegments = $this->storedSegmentService->getAllSegmentsAndIgnoreVisibility();
|
|
|
|
$idSegments = array();
|
|
foreach ($allSegments as $segment) {
|
|
if ($segmentExpression->getSegmentDefinition() == $segment['definition']) {
|
|
$idSegments[] = $segment['idsegment'];
|
|
}
|
|
}
|
|
return $idSegments;
|
|
}
|
|
}
|