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

Compare rule "Watchlisted by" against empty ruleset #1249

Open
TuGeek opened this issue Sep 4, 2024 · 23 comments
Open

Compare rule "Watchlisted by" against empty ruleset #1249

TuGeek opened this issue Sep 4, 2024 · 23 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@TuGeek
Copy link

TuGeek commented Sep 4, 2024

Describe the bug
I'm trying to create a rule that says "if 'Watchlisted by' is empty [] then true to delete it" but when I compare the empty list with the string "[]" it tells me it's false.

To Reproduce
image

Expected behavior
Since the list is empty and I compare it with an empty list, it should give "true" in the rule.
image

Device (please complete the following information):

  • OS: Docker
  • Version 2.1.0
@TuGeek TuGeek changed the title Comparte rule "Watchlisted by" against empty ruleset Compare rule "Watchlisted by" against empty ruleset Sep 4, 2024
@ydkmlt84
Copy link
Collaborator

ydkmlt84 commented Sep 24, 2024

I just had a thought about this and wanted to share. What if you said watchlisted by, not contains, everyone. Then I would assume it would return as true.

@TuGeek
Copy link
Author

TuGeek commented Sep 25, 2024

I just had a thought about this and wanted to share. What if you said watchlisted by, not contains, . Then I would assume it would return as true.

Thats the result with different combinations:
(equals)
image

(not_equals)
image

(contains)
image

(not_contains)
image

(contains_partial)
image

(not_contains_partial)
image

@ydkmlt84
Copy link
Collaborator

ydkmlt84 commented Sep 25, 2024

Well, in the formatting of my post I used <> and when it was actually posted it removed that section. So I will try again.

What I was trying to say is, what if you put a random name in there. Equaling no one is the same as not equaling (James, Lisa, Mary, John, Frank). So if you are looking for stuff that is watchlisted by no one, could you say not contains and list everyone?
So that when it is comparing it will return true if the list is empty because it wouldn't equal/contain their names?

I don't know if I am making sense but basically equals no one is the same as not equals everyone.

@TuGeek
Copy link
Author

TuGeek commented Sep 25, 2024

Now I think I understand you, but in that case I would need to know the list of all possible people to compare it with the list of people who have seen the item. And for that I would need to have something like "All Plex users".

I hope you understood me now... :)

@ydkmlt84
Copy link
Collaborator

I thought you were just looking for stuff not watchlisted by anyone.

@TuGeek
Copy link
Author

TuGeek commented Sep 25, 2024

Yes, that would be what I'm looking for. Can you think of a way to do it?

@ydkmlt84
Copy link
Collaborator

Yes, that would be what I'm looking for. Can you think of a way to do it?

Thats what I was trying to say earlier. Equaling no one is the same as not equaling everyone/anyone. So you could say not contains and list everyone. Then it would return true as it wouldn't equal anyone. Instead of trying to equal blank to blank. Change it to not equaling a list of everyone.

@ydkmlt84
Copy link
Collaborator

Yes, that would be what I'm looking for. Can you think of a way to do it?

Also are we sure we're even talking about the same thing? Watchlisted and a "list of watches" are different things. Watchlisted is a feature in Plex where you can add something to your watchlist (or your "want to watch list").
Looking for people who watched something is a different thing. Just wanted to clarify.

@TuGeek
Copy link
Author

TuGeek commented Sep 26, 2024

It's hard to explain in writing, and we might be a bit lost in translation... I'm not an English speaker and I might be wrong about something.

My idea is to be able to make a rule that allows a certain item to be deleted when it is not included in anyone's Watchlist.

So, my first idea was "if the rule 'Watchlisted by' is empty" it means that no one has it in their watchlist.

I hope I'll finally be able to get my ideas across to you :)

@ydkmlt84
Copy link
Collaborator

It's hard to explain in writing, and we might be a bit lost in translation... I'm not an English speaker and I might be wrong about something.

My idea is to be able to make a rule that allows a certain item to be deleted when it is not included in anyone's Watchlist.

So, my first idea was "if the rule 'Watchlisted by' is empty" it means that no one has it in their watchlist.

I hope I'll finally be able to get my ideas across to you :)

I understand completely. We're on the same page there.
How you would do it is put everyone's name whose watchlist it could be in, and say not equals. That is the same as equaling empty.
What is the exact opposite of being in no one's watchlist?

@TuGeek
Copy link
Author

TuGeek commented Sep 26, 2024

I had thought about enabling the comparison of empty arrays and being able to do the reverse, that is, whenever "Watchlisted by" is an empty array "[]" and I compare it with the empty array text "[]" and it is "equal" it should give True. For me it is comparing 2 empty strings, which in essence should be the same. When someone has watchlisted it, the array would be "[John Doe, Jane Doe]" and when comparing with an empty array "[]" with the "equal" rule it would give False

@ydkmlt84
Copy link
Collaborator

What do you mean when someone has seen it?

@TuGeek
Copy link
Author

TuGeek commented Sep 26, 2024

What do you mean when someone has seen it?

When someone "Watchlisted", sorry... -_-

@ydkmlt84
Copy link
Collaborator

You should come over to discord and we can DM about it.

@ydkmlt84 ydkmlt84 added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 5, 2024
@henryjrobertson
Copy link

I have same issue, I think. Was there was a resolution discussed elsewhere? Ideally, I just want to add a rule so a title won't get deleted if anyone has it in their watchlist. Trying to match on [] and [] doesn't seem to work when I test with something that has a watchlist attached.

@ydkmlt84
Copy link
Collaborator

You don't want to delete something if it's on the watchlist of someone, right?

The solution is to put not contains and list all users ["user1","user2","user3", "etc"]. It's reverse logic. So, equals no one is the same as doesn't equal everyone.

@henryjrobertson
Copy link

henryjrobertson commented Oct 15, 2024

Thanks for the reply! I actually picked this up off the Discord chat history after I posted.

firstValue: Plex.watchlist_isListedByUsers
      action: NOT_EQUALS
      lastValue: Plex.watchlist_isListedByUsers

Works for my use case without listing all the Users manually. If any Users have media in a watchlist, it will return false.

@ydkmlt84
Copy link
Collaborator

Nice. I am glad you found your answer!

@bitnimble
Copy link
Contributor

bitnimble commented Jan 23, 2025

Heya, the most recent workaround doesn't seem to work anymore (empty list != empty list is returning false for me), so I just wanted to bump this ticket.

I'm a developer and I'm happy to raise a PR to implement this as a feature, if it's reasonable to simply add "Empty list" as a match value, i.e.:

Image

While doing != [user1, user2, user3, ...] works, it's a bit inelegant and can be very tedious to enumerate every single Plex user (especially if you have a lot of users on your server), not to mention you have to go update the list every time a new Plex user joins the server. I also don't think it's top-of-mind as a solution when somebody wants to simply match against an empty list, as demonstrated by the existence of this Github issue.

LMK if that seems reasonable and I can go ahead and raise a PR :)

(such a matcher would also be very useful for all other list[] values, especially ones where you can't simply enumerate all of the possible values easily, like Labels)

@benscobie
Copy link
Collaborator

benscobie commented Jan 23, 2025

Heya, the most recent workaround doesn't seem to work anymore (empty list != empty list is returning false for me), so I just wanted to bump this ticket.

You shouldn't need to workaround this any more if I'm understanding your scenario correctly. An empty list to empty list comparison should return true when using equals (OPs original issue), so you can do that instead. You can use not equals empty list for the inverse.

With regards to your suggestion, something I'd like to implement for lists is Count equals, Count not equals, Count greater & Count smaller. I believe that'll be more flexible.

@bitnimble
Copy link
Contributor

Yep, after cloning and reading through the code and finding the isStringParsableToArray bit in the comparator, just realised that equals [] works just fine. I swear I tried that the first time around when I first started using Maintainerr and it didn't work... maybe I was just crazy. Well, I'm happy at least :)

re: count - that sounds reasonable and definitely more flexible. Still happy to raise a PR for that if you think that it's a decent first task into the repo :)

@benscobie
Copy link
Collaborator

benscobie commented Jan 23, 2025

Yep, after cloning and reading through the code and finding the isStringParsableToArray bit in the comparator, just realised that equals [] works just fine. I swear I tried that the first time around when I first started using Maintainerr and it didn't work... maybe I was just crazy. Well, I'm happy at least :)

Not crazy haha, this was fixed in v2.7.0

re: count - that sounds reasonable and definitely more flexible. Still happy to raise a PR for that if you think that it's a decent first task into the repo :)

We'd be very happy to accept that. I just had a very brief look at a possible implementation; add a new RuleType (RuleType.TEXT_ARRAY?) with new RulePossibility's (RulePossibility.COUNT_EQUALS etc.) in rules.constants.ts. Then update the [list] ones to return that instead of RuleType.TEXT. That can then be used in the UI to show the correct actions. After that it should just be a case of updating rule.comparator.service.ts with the new comparisons and some tests. I am @Scoob on the Maintainerr Discord if you have any questions.

@ydkmlt84
Copy link
Collaborator

Just to put my two cents in here, there is also a new rule in the dev branch that just returns true or false if the item is watchlisted by anyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants