terminus icon indicating copy to clipboard operation
terminus copied to clipboard

[FEAT-596] Add multiple tag filter support

Open kyletaylored opened this issue 4 years ago • 4 comments

  • Add the ability to provide a comma-separated list of tags to --tag that will return a list of sites that have ANY tag in the list. (fixes #1790)
  • Add an additional --tags option which takes a comma-separated list of tags, but requires ALL tags to match.
  • Now supports NO tags and will return only sites with no tags if the tag option value is empty (fixes #1845)

The summary of this PR is extending the functionality of the existing --tag option to support multiple tags as a comma-separated string, in addition to adding a --tags option which is more explicit. These also support single tag values as to not alter the previous behavior.

  • --tag will return sites matching ANY tag
  • --tags will return sites that match ALL tags
  • Both options will return all sites with NO tags if the value is an empty string (--tag "")

I added 3 methods to the TerminusCollection in addition to the binary has() method:

  • containsAny - if any provided ID matches
  • containsAll - if all provided IDs match
  • containsNone - Match if an empty ID was provided with sites with no ID

What about --filter? While the --filter option can work, it is more restrictive in terms of both functionality and results. The tag field is parsed as a single, combined string, which causes unexpected results.

  1. Single tag (--filter "tags=tagA") This will only return a list of sites that have only this one tag. If the site has other tags, this fails.

  2. More than one tag (--filter "tags=tagA||tags=tagB") Similar to a single tag, only shows a list of sites if they solely contain each tag, and it disregards other tags.

  3. More than one tag, but listed alphabetically (--filter "tags=tagA,tagB") Will only list sites that have both tags (none others), and they must be listed in alphabetical order. If you were switch the order of the tags (tagB,tagA), then you will get no results.

kyletaylored avatar Dec 04 '20 03:12 kyletaylored

Sorry, that we're just now getting to this, but we haven't really had anyone working on Terminus in a while. I'll try to rebase around the changes we're including in v3.0 and and see if I can tease out just your tag changes. Gimme a day or so to work out the diff.

stovak avatar Jun 28 '21 23:06 stovak

Note also that the underlying API that Terminus uses does not report all tags, so this PR will not behave correctly in all circumstances.

greg-1-anderson avatar Jun 29 '21 01:06 greg-1-anderson

@greg-1-anderson What is the underlying API that is used, and do you have recommendations on how to address those? Or just pointing out the potential issue as a heads up?

kyletaylored avatar Jul 19 '21 19:07 kyletaylored

@greg-1-anderson @stovak Would it be possible to revisit this PR? Getting the right tag data from the platform API should be a separate issue, but in this case we're just applying the correct logic to the data that is available. // cc @danny2p

kyletaylored avatar Feb 17 '22 23:02 kyletaylored

Terminus 2 is EOL now so closing this PR. We'll get this merged into Terminus 3 soon

kporras07 avatar Feb 27 '23 16:02 kporras07