monkeytype icon indicating copy to clipboard operation
monkeytype copied to clipboard

feat(filters): Add new tag filtering modes `AND`, `EXACT` & `NOT` (@TristanMarion)

Open TristanMarion opened this issue 9 months ago • 7 comments

Description

This PR implements issue #4239, which adds a new toggle feature to switch between OR, AND and EXACT logic modes for tag filtering in the account page :

  • OR: any selected tag must match
  • AND: all selected tags must match
  • EXACT: exactly the selected tags must match

Expected behaviors :

  • AND mode
    • none - Results without tags
    • tags - Results tags should include the selected tag/tags
    • none and tag - Nothing
    • all (or no tag) - Nothing
  • OR mode
    • none - Results without tags
    • tags - Result tags should include any of the selected tags
    • none and tag - Result without tags plus result tags should include any of the selected tags
    • all (or no tag) - Everything
  • EXACT mode
    • none - Results without tags
    • tags - Results tags should exactly match the selected tags
    • none and tag - Nothing
    • all (or no tag) - Nothing

Checks

  • [x] Check if any open issues are related to this PR; if so, be sure to tag them below.
  • [x] Make sure the PR title follows the Conventional Commits standard. (https://www.conventionalcommits.org for more info)
  • [x] Make sure to include your GitHub username prefixed with @ inside parentheses at the end of the PR title.

Closes #4239

Several checks in video :

Dataset used

We will mainly have tag 1, 2 and 3 for our tests, the list of test tags is : 1, 2, 3, 1,2, 1,3, 2,3, 1,2,3

https://github.com/user-attachments/assets/d4afb820-e2bc-4d9b-b447-0b2cf69679a3

OR mode with tag 1 : we only have 1, 1,2, 1,3 & 1,2,3

https://github.com/user-attachments/assets/f0502cc2-1205-482e-8687-0191c41dae9a

OR mode with tags 1 & 2 : we only have 1, 2, 1,2, 2,3, 1,3 & 1,2,3

https://github.com/user-attachments/assets/300b251d-c41a-4d12-b138-88c60f8c2e86

AND mode with tags 1 & 2 : we only have 1,2 & 1,2,3

https://github.com/user-attachments/assets/5b63ca2d-3433-4752-8d83-585d8081a9ad

EXACT mode with tags 1 & 2 : we only have 1,2

https://github.com/user-attachments/assets/8f65fa8c-c7f0-401e-bd4d-0f9e9875ad59

EXACT mode with tag 1 : we only have 1

https://github.com/user-attachments/assets/ab5781eb-9c0c-48ec-841f-51ab04475285

AND mode with tag 1 (same behavior as OR with tag 1) : we only have 1, 1,2, 1,3 & 1,2,3

https://github.com/user-attachments/assets/a2df3287-9470-4b0f-b754-89bebac736c1

TristanMarion avatar Mar 21 '25 14:03 TristanMarion

Continuous integration check(s) failed. Please review the failing check's logs and make the necessary changes.

github-actions[bot] avatar Mar 21 '25 14:03 github-actions[bot]

Nice! How about we also add an 'exact' mode, where result tags have to exactly match your selection?

Miodec avatar Mar 21 '25 16:03 Miodec

Thanks for the feedbacks 😊 indeed this was intended to have a non exclusive AND (to match at least the tags selected but not all the tags) but if you think that it should be an exact match I can perform the change 👍 Let me know what you prefer and I’ll update it 👌

TristanMarion avatar Mar 21 '25 22:03 TristanMarion

Thanks for the feedbacks 😊 indeed this was intended to have a non exclusive AND (to match at least the tags selected but not all the tags)

My bad, I see the use case now. However, I think an "exact" mode would be equally useful. This is just my free opinion as a user, it is up to miodec if he prefers 3 modes or 2.

nadalaba avatar Mar 22 '25 09:03 nadalaba

Lets have 3 modes, or, non exclusive and and exclusive and (exact mode). Click the button to cycle through them.

Miodec avatar Mar 22 '25 10:03 Miodec

Pretty clear, I’ll handle the changes to match the expected behaviour. Makes sense to have the three modes 👌

TristanMarion avatar Mar 22 '25 13:03 TristanMarion

I've reorder the imports to reduce the number of line changed 👍 (and to keep the same import order as before too 😅 )

TristanMarion avatar Mar 23 '25 17:03 TristanMarion