Issue fork facets-3047910

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

niko- created an issue. See original summary.

niko-’s picture

Title: Or condition for dependent facets processor » Add or condition for dependent facets processor
niko-’s picture

Title: Add or condition for dependent facets processor » Add AND\OR condition for dependent facets processor
niko-’s picture

Status: Active » Needs review
StatusFileSize
new2.81 KB

Status: Needs review » Needs work

The last submitted patch, 4: dependent-or-condition-3047910-4.patch, failed testing. View results

kienan’s picture

The patch worked for me and seems good. I think the tests just need to be updated or something since they complain about unknown property operator: as if the object saved didn't have the data on it. Haven't looked how the facets are added in the test suite, so I'm not sure if my guess is tending in the right direction.

mhavelant’s picture

I tested the patch, and I have the following notes:

  • There are some performance-related things that could be done, namely early exits from the loop (e.g. when the condition is TRUE and the operator is OR iterating further is not needed). Using a boolean variable instead of an array would also help with memory usage.
  • The schema expects plugin.plugin_configuration.facets_processor.dependent_processor as the processor settings, operator: boolean does not conform to that. The schema needs to be updated to a mapping with operator (boolean) and facets (plugin.plugin_configuration.facets_processor.[%parent.processor_id]). This also requires an update hook for migrating the configs to the new schema.
  • As mentioned above, tests need to be updated or added

Grimreaper made their first commit to this issue’s fork.

grimreaper’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Assigned: Unassigned » grimreaper

Hi,

I will try to update the patch and switch to MR workflow.

grimreaper’s picture

Regarding comment 7.

- Config schema fixed with hook_update_N to update it.
- Existing tests fixed.
- Currently adding new ones.

I am not sure about the performance optimization, focusing on tests so this kind of refactoring will be covered.

Also realizing that tests/src/Unit/Plugin/processor/DependentFacetProcessorTest.php does not cover all the existing cases ('values').

grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs work » Needs review

New test added.

grimreaper’s picture

mkalkbrenner’s picture

The patch looks good to me, but it would good to have someone confirming that it works in their setup. Especially the update hook!

anybody’s picture

@mhavelant, @kienan, @niko- could you perhaps test and review the patch (https://git.drupalcode.org/project/facets/-/merge_requests/57.diff) to push things forward here, as you reported the error or added useful information?

It would help a lot to get feedback if it's working in your setup! (And might fix your issues)

Thanks a lot in advance :)

grimreaper’s picture

Assigned: Unassigned » grimreaper
mkalkbrenner’s picture

Status: Needs review » Needs work

Unfortunatley this patch needs to be adjusted to the changes introduced by #2908937: Dependend Facets don't reset after Conditions are not met anymore..

grimreaper’s picture

Assigned: grimreaper » Unassigned

@mkalkbrenner: I am not sure how to solve the last failing test as it may be an edge case of #2908937: Dependend Facets don't reset after Conditions are not met anymore..

I attached the results of locally runned tests.

In the HTML we can see "Displaying 3 search results"

The URL is /search-api-test-fulltext?f%5B0%5D=dependingfacet%3Agrape so the depending facet is not reset.

mkalkbrenner’s picture

Status: Needs work » Needs review
StatusFileSize
new2.07 KB
new16.19 KB

Status: Needs review » Needs work

The last submitted patch, 19: 3047910.patch, failed testing. View results

mkalkbrenner’s picture

Status: Needs work » Needs review
StatusFileSize
new10.25 KB
new19.6 KB
mkalkbrenner’s picture

@mkalkbrenner: I am not sure how to solve the last failing test as it may be an edge case of #2908937: Dependend Facets don't reset after Conditions are not met anymore..

It is not an edge case, you broke the feature entirely ;-)

You changed the structure of the of the conditions but you didn't adjust it in the DefaultFacetManager accordingly:

+++ b/src/FacetManager/DefaultFacetManager.php
@@ -118,7 +118,7 @@ class DefaultFacetManager {
+        foreach ($conditions['facets'] as $facet_id => $condition) {
mkalkbrenner’s picture

RTBC?

grimreaper’s picture

Assigned: Unassigned » grimreaper

Hi,

Thanks for the updated patch.

I didn't thought to look outside the plugin!

Way cleaner code by the way!

Testing locally quickly.

grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs review » Needs work
StatusFileSize
new6.07 MB

Hum, I have reinstalled facets after applying the patch from comment 21.

I have recorded my test as a Gif.

Two problems.

With AND: if I select a value in the depending facet and unselect a dependent facet you can see that the value is not removed in the URL and still applied.

With OR: Facet "ID" is displayed when both other facets have a value whereas it should be when one has a value.

I don't know then if tests coverage is enough.

grimreaper’s picture

Issue tags: +ddd2022
Denis Degtyarev’s picture

StatusFileSize
new20.05 KB
new8.89 KB

Rerolled patch from comment #21 against version 2.0.6. Didn't test comment #25.