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

Extend filter behavior #51

Closed
wants to merge 10 commits into from
Closed

Extend filter behavior #51

wants to merge 10 commits into from

Conversation

cjbt
Copy link
Collaborator

@cjbt cjbt commented Feb 14, 2023

closes #35

Support for multi conditions in filter array operation.
Includes updated documentation.

@cjbt cjbt changed the title Ugly but working Multi Condition Filtering Feb 14, 2023
@cjbt cjbt marked this pull request as ready for review February 14, 2023 07:05
@cjbt cjbt requested review from justsml and chhatch February 14, 2023 07:10
@cjbt
Copy link
Collaborator Author

cjbt commented Feb 14, 2023

After thinking about this a little bit more, maybe this change would not be enough. Maybe introducing the "if" rule for the filter array be a better fit here. Currently (even with this change) there aren't any ways to filter by "many" multiple conditions. This change only supports one multiple conditions.

// if - many multiple conditions (current behavior)
{
  if: { and: [conditionOne, conditionTwo]}
  then: { stuff }
},
{
  if: { and: [anotherConditionOne, anotherConditionTwo]}
  then: { stuff }
}

// based on this PR
// filter - works
{
  filter: 'list'
  run: { and:  [conditionOne, conditionTwo]}
  set: 'results'
}
// filter - does not work
{
  {
    filter: 'list'
    run: { and:  [conditionOne, conditionTwo]}
    set: 'results'
  },
  {
    filter: 'list'
    run: { and:  [anotherConditionOne, anotherConditionTwo]}
    set: 'results'
  }
}

This is essentially combining both the and and the or.

return conditionOne && conditionTwo || anotherConditionOne && anotherConditionTwo

possible proposed solution

{
  filter: 'list'
  run: {
    {
      if: { and: [conditionOne, conditionTwo]}
      then: { stuff } // optional?
    },
    {
      if: { and: [anotherConditionOne, anotherConditionTwo]}
      then: { stuff } // optional?
    }
  }
  set: 'results'
}
{
  {
    filter: 'list'
    run: { and:  [conditionOne, conditionTwo]}
    set: 'results'
  },
  {
    filter: 'list'
    run: { and:  [anotherConditionOne, anotherConditionTwo]}
    set: 'results'
  }
}

I need to grok on this a little bit more

@cjbt cjbt changed the title Multi Condition Filtering Extend filter behavior Feb 15, 2023
@cjbt cjbt closed this Feb 15, 2023
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.

Returns Affect Subsequent Rules
1 participant