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

Exclude filters in aggregations conditionally #230

Open
wants to merge 3 commits into
base: 1.x
Choose a base branch
from

Conversation

jremmurd
Copy link
Contributor

@jremmurd jremmurd commented Feb 24, 2025

This PR adds a method to exclude specific filters in the "groupByValues" logic.

There is no breaking change, its just extending the existing possibilities of adjusting the returned aggregation values.

Example:

I have 2 fields which are displayed as one filter in the frontend, lets say sale categories and regular categories. Now I want to exclude the category filter for the sale category filter and vice versa, but I do not want to exclude them for any other filter.

With the new function I now can do something like this:

    ...
    protected function groupByValuesSpecificFilterExcludes(string $fieldname, array $config): array
    {
        $currentShortFieldname = $this->getTenantConfig()->getReverseMappedFieldName($fieldname);

        // do not consider sale filters for category filter counts and vice versa
        return match ($currentShortFieldname) {
            $saleFieldName => [
                $categoriesFieldName => $categoriesFieldName
            ],
            $categoriesFieldName => [
                $saleFieldName => $saleFieldName
            ]
            default => []
        };
    }

Copy link

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


jnuernberger seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request

@jremmurd
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant