@diosmosis opened this Pull Request on October 22nd 2022 Member

Description:

This PR adds a new method to DataTable and DataTable\Map classes, multiFilter, which makes it easier to iterate over multiple DataTable\Map's concurrently (a pattern that happens fairly often in my experience).

Basic usage:

public function getMyReport($idSite, $period, $date, $segment = false)
{
    $data = Archive::createDataTableFromArchive($recordName, $idSite, $period, $date, $segment);

    $pageUrls = Request::processRequest('Actions.getPageUrls', [
        'idSite' => $idSite,
        'period' => $period,
        'date' => $date,
        'segment' => $segment,
    ]);

    $data->multiFilter([$pageUrls], function (DataTable $table, $pageUrlTable) {
        if (empty($pageUrlTable)) {
            return;
        }

        $extraProcessedMetrics = $table->getMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME) ?? [];
        $extraProcessedMetrics[] = new PageviewMetricRate($pageUrlTable);
        $table->setMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME, $extraProcessedMetrics);
    });
}

Review

@github-actions[bot] commented on October 30th 2022 Contributor

This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers

Powered by GitHub Issue Mirror