Skip to content

Conversation

@guisoares1
Copy link
Contributor

@guisoares1 guisoares1 commented Jan 22, 2024

Description

Implemented two new operators in the query system: ‘in’ and ‘notIn’.
The ‘in’ operator checks if a given value is present in an array.
The ‘notIn’ operator is the opposite of the ‘in’ operator.

Useful links

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.

  • I intercepted the request in the back end that handles the filters (all.ts, line 401) and built a json object for testing purposes.

Screenshots

Result of tests

Base filter test object:

{
  "logic": "and",
  "filters": [
    {
      "logic": "and",
      "filters": [
        {
          "logic": "and",
          "filters": []
        }
      ]
    },
    {
      "logic": "and",
      "filters": [
        {
          "field": "name",
          "operator": "in",
          "value": ["elemento1", "elemento2", "elemento3"]
        }
      ]
    }
  ]
}

Result to "in":

{
  "$and": [
    {
      "$and": [
        {}
      ]
    },
    {
      "$and": [
        {
          "data.name": {
            "$in": [
              "elemento1",
              "elemento2",
              "elemento3"
            ]
          }
        }
      ]
    }
  ]
}

Result to "notin":

{
  "$and": [
    {
      "$and": [
        {}
      ]
    },
    {
      "$and": [
        {
          "data.name": {
            "$nin": [
              "elemento1",
              "elemento2",
              "elemento3"
            ]
          }
        }
      ]
    }
  ]
}

Checklist:

( * == Mandatory )

  • * I have set myself as assignee of the pull request
  • * My code follows the style guidelines of this project
  • * Linting does not generate new warnings
  • * I have performed a self-review of my own code
  • * I have put the ticket for review, adding the oort-backend team to the list of reviewers
  • * I have commented my code, particularly in hard-to-understand areas
  • * I have put JSDoc comment in all required places
  • * My changes generate no new warnings
  • * I have included screenshots describing my changes if relevant
  • * I have selected labels in the Pull Request, according to the changes with code brings
  • I have made corresponding changes to the documentation ( if required )
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

More explanation

https://www.loom.com/share/05a716d61b9744faaf51fb304c21d1e5?sid=f87cf896-582a-4f76-93ae-8ceed801b145

@guisoares1 guisoares1 self-assigned this Jan 22, 2024
@guisoares1 guisoares1 added the enhancement Existing feature label Jan 22, 2024
@guisoares1 guisoares1 marked this pull request as draft January 22, 2024 20:22
@guisoares1 guisoares1 marked this pull request as ready for review January 23, 2024 14:58
@guisoares1 guisoares1 requested a review from a team January 23, 2024 14:58
@MwanPygmay MwanPygmay requested review from MwanPygmay and removed request for a team January 25, 2024 12:50
Copy link
Contributor

@MwanPygmay MwanPygmay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guisoares1 working well for resources, but did not work for reference data, created front-end branch for it, will edit the pr

}
case 'notin': {
if (isAttributeFilter) {
if (MULTISELECT_TYPES.includes(type)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MwanPygmay
is there any reason why this is so different from the solution proposed in the first file?

@AntoineRelief AntoineRelief merged commit e850042 into 2.x.x Apr 26, 2024
@AntoineRelief AntoineRelief deleted the AB#84023-add-in-and-notIn-operator-for-dashboard-filters branch April 26, 2024 14:52
AntoineRelief pushed a commit that referenced this pull request Apr 29, 2024
# [2.9.0](v2.8.0...v2.9.0) (2024-04-29)

### Bug Fixes

* Graphql questions would not display text values in history downloads [#91235](https://github.com/ReliefApplications/ems-backend/issues/91235) ([#1026](#1026)) ([676f035](676f035))

### Features

* Add 'in' and 'notIn' operators for record queries ([#951](#951)) ([e850042](e850042))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants