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

[Feature request] List users not suscribed to any list #1562

Closed
jorge-vitrubio opened this issue Oct 18, 2023 · 4 comments
Closed

[Feature request] List users not suscribed to any list #1562

jorge-vitrubio opened this issue Oct 18, 2023 · 4 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@jorge-vitrubio
Copy link
Contributor

We have had some spam users created as contacts to the listmonk, but because they are opt-in newsletters this has had no effect so far except that they are on the DB but not in any list

Would be good to know how to query or select all contacts that are not subscribed to no list so they could be deleted or filtered for whatever purpouse.

There might be a way usin sql queries that I don´t know

thanks in advance

@jorge-vitrubio jorge-vitrubio added the enhancement New feature or request label Oct 18, 2023
@MaximilianKohler
Copy link
Contributor

You can remove them under /admin/settings/maintenance -> orphans, but I'd like to be able to view and download them [first]. I don't know of a way to do that though.

@knadh
Copy link
Owner

knadh commented Oct 23, 2023

NOT EXISTS (SELECT 1 FROM subscriber_lists sl WHERE sl.subscriber_id = subscribers.id)

This should give subscribers who are not in any lists.

@knadh knadh closed this as completed Oct 23, 2023
@knadh knadh added the question Further information is requested label Oct 23, 2023
@MaximilianKohler
Copy link
Contributor

That didn't work for me.

psql -U listmonk -h localhost -p 5432 listmonk
Password for user listmonk:
psql (15.5)
Type "help" for help.

listmonk=> NOT EXISTS (SELECT 1 FROM subscriber_lists sl WHERE sl.subscriber_id = subscribers.id)
listmonk->

It should be returning at least 2 results:
2 orphans

@MaximilianKohler
Copy link
Contributor

MaximilianKohler commented Jan 18, 2024

I thought it was just missing the semicolon at the end, but when I added it there's an error:

listmonk=> NOT EXISTS (SELECT 1 FROM subscriber_lists sl WHERE sl.subscriber_id = subscribers.id);
ERROR:  syntax error at or near "NOT"
LINE 1: NOT EXISTS (SELECT 1 FROM subscriber_lists sl WHERE sl.subsc...
        ^
listmonk=>

It looks like the proper command https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-exists/ is:

SELECT *
FROM subscribers
WHERE NOT EXISTS
    (SELECT 1
     FROM subscriber_lists sl 
     WHERE sl.subscriber_id = subscribers.id);

You can copy-paste all those lines at once and hit enter.

EDIT: Oh, knahd's command works from listmonk's UI -- /admin/subscribers -> advanced SQL search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants