Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add multiFilter utility method to DataTable classes #19902

Merged
merged 1 commit into from Feb 6, 2023

Conversation

diosmosis
Copy link
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

@diosmosis diosmosis added the Needs Review PRs that need a code review label Oct 22, 2022
@github-actions
Copy link
Contributor

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

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label Oct 30, 2022
@github-actions
Copy link
Contributor

This PR was last updated more than one month ago, maybe it's time to close it. Please check if there is anything we still can do or close this PR. ping @matomo-org/core-reviewers

@github-actions github-actions bot added the Stale for long The label used by the Close Stale Issues action label Dec 12, 2022
@sgiehl sgiehl removed Stale The label used by the Close Stale Issues action Stale for long The label used by the Close Stale Issues action labels Feb 6, 2023
…o iterate over multiple DataTables concurrently
@sgiehl sgiehl added this to the 5.0.0 milestone Feb 6, 2023
@sgiehl sgiehl merged commit e6e0027 into 5.x-dev Feb 6, 2023
@sgiehl sgiehl deleted the datatable-multi-filter branch February 6, 2023 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants