- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 2.9k
 
          feat(filters): Add new tag filtering modes AND, EXACT & NOT (@TristanMarion)
          #6388
        
          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
base: master
Are you sure you want to change the base?
  
    feat(filters): Add new tag filtering modes AND, EXACT & NOT (@TristanMarion)
  
  #6388
              Conversation
| 
           Continuous integration check(s) failed. Please review the failing check's logs and make the necessary changes.  | 
    
b71dc32    to
    c5fea36      
    Compare
  
    | 
           Nice! How about we also add an 'exact' mode, where result tags have to exactly match your selection?  | 
    
| if (enabledTagIds.length === 0) { | ||
| // No tag filters enabled, show everything | ||
| tagHide = false; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since "none" does not get pushed to enabledTagIds, does this mean when only "none" is enabled, all results (with & without tags) will be shown?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, TBH I did not know how to handle this edge case, do you think we should display only the tests with no tags at all ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, behavior-wise, only results with no tags should be shown imo.
Implementation-wise, I don't think these 3 lines are needed here (I did not test this however)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this is already done in the existing code and this block won't be reachable if the result has no tag so I will remove this part and ensure we have the correct behavior anyway
| const resultHasAllTags = enabledTagIds.every((tagId) => | ||
| result.tags?.includes(tagId) | ||
| ); | 
      
        
              This comment was marked as resolved.
        
          
      
    
    This comment was marked as resolved.
Sorry, something went wrong.
| 
           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 👍  | 
    
          
 My bad, I see the use case now. However, I think an "exact" mode would be equally useful.  | 
    
| 
           Lets have 3 modes, or, non exclusive and and exclusive and (exact mode). Click the button to cycle through them.  | 
    
| 
           Pretty clear, I’ll handle the changes to match the expected behaviour. Makes sense to have the three modes 👌  | 
    
AND (@TristanMarion)AND & EXACT (@TristanMarion)
      81ab42a    to
    407c003      
    Compare
  
    | 
           I've reorder the imports to reduce the number of line changed 👍 (and to keep the same import order as before too 😅 )  | 
    
        
          
                frontend/src/ts/pages/account.ts
              
                Outdated
          
        
      | } else if ( | ||
| ResultFilters.getFilter("tags", "none") && | ||
| result.tags.length === 0 | ||
| ) { | ||
| // Special case: "none" tag is enabled and result has no tags | ||
| tagHide = false; | ||
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this block will never be reached (it is in an else block that gets executed when result.tags.length > 0), I wonder why the linter didn't complain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I will remove it, I'll test what happens with the none tag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handled in 70c1f31 👍
Indeed the code is already handling this case earlier 😅
        
          
                frontend/src/ts/pages/account.ts
              
                Outdated
          
        
      | } else if ( | ||
| ResultFilters.getFilter("tags", "none") && | ||
| result.tags.length === 0 | ||
| ) { | ||
| // Special case: "none" tag is enabled and result has no tags | ||
| tagHide = false; | ||
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this block will never be reached
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handled in 70c1f31 👍
70c1f31    to
    967d66d      
    Compare
  
    | merged[groupKey] = id; | ||
| } else if (groupKey === "name") { | ||
| merged[groupKey] = filters[groupKey] ?? defaultResultFilters[groupKey]; | ||
| } else if (groupKey === "tagsFilterMode") { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can merge this condition with the previous one as they contain the same code, let me know what you prefer
AND & EXACT (@TristanMarion)AND, EXACT & NOT (@TristanMarion)
      
Description
This PR implements issue #4239, which adds a new toggle feature to switch between
OR,ANDandEXACTlogic modes for tag filtering in the account page :OR: any selected tag must matchAND: all selected tags must matchEXACT: exactly the selected tags must matchExpected behaviors :
ANDmodenone- Results without tagsnoneand tag - Nothingall (or no tag)- NothingORmodenone- Results without tagsnoneand tag - Result without tags plus result tags should include any of the selected tagsall (or no tag)- EverythingEXACTmodenone- Results without tagsnoneand tag - Nothingall (or no tag)- NothingChecks
Closes #4239
Several checks in video :
Dataset used
We will mainly have tag
1,2and3for our tests, the list of test tags is :1,2,3,1,2,1,3,2,3,1,2,3Screen.Recording.2025-03-23.at.14.52.55.mov
ORmode with tag1: we only have1,1,2,1,3&1,2,3Screen.Recording.2025-03-23.at.14.53.59.mov
ORmode with tags1&2: we only have1,2,1,2,2,3,1,3&1,2,3Screen.Recording.2025-03-23.at.14.54.15.mov
ANDmode with tags1&2: we only have1,2&1,2,3Screen.Recording.2025-03-23.at.14.54.29.mov
EXACTmode with tags1&2: we only have1,2Screen.Recording.2025-03-23.at.14.54.43.mov
EXACTmode with tag1: we only have1Screen.Recording.2025-03-23.at.14.54.53.mov
ANDmode with tag1(same behavior asORwith tag1) : we only have1,1,2,1,3&1,2,3Screen.Recording.2025-03-23.at.14.55.03.mov