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

Prune subscribers who haven't opened an email in X time #1107

Closed
ajoslin opened this issue Dec 17, 2022 · 4 comments
Closed

Prune subscribers who haven't opened an email in X time #1107

ajoslin opened this issue Dec 17, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@ajoslin
Copy link

ajoslin commented Dec 17, 2022

Hi, first of all thanks love your project. Way more polished and simple than similar OSS alternatives, and am making extensive use of the multiple SMTP provider support.

Feature question: I’d like to delete subscribers who haven't opened any email in last X weeks.

Is there a way to do this or to query for this?

@ajoslin ajoslin added the enhancement New feature or request label Dec 17, 2022
@MaximilianKohler
Copy link
Contributor

Being able to resend to unopens would be nice too, but as far as I can tell, there is no tracking of who opened or didn't open, despite the "Individual subscriber tracking" setting.

Also, open tracking is very inaccurate anyway #1025, so I don't think deleting unopens is a good idea.

@ajoslin
Copy link
Author

ajoslin commented Dec 18, 2022

I guess will have to dig into the source code and see if it's possible with a cron job

@knadh
Copy link
Owner

knadh commented Dec 25, 2022

You can set a psql cron with something like this.

DELETE FROM subscribers WHERE id = (
     SELECT subscribers.id FROM subscribers LEFT JOIN campaign_views
     ON (subscribers.id = campaign_views.subscriber_id)
     WHERE campaign_views.created_at < NOW() - INTERVAL '14 days'
);

@knadh knadh closed this as completed Dec 25, 2022
@ajoslin
Copy link
Author

ajoslin commented Mar 7, 2023

Coming back to say - did this to prune all >60 day old subscribers who haven't opened in 60 days. Thanks @knadh

DELETE FROM subscribers where id in (
  select DISTINCT(subscribers.id) FROM subscribers 
  LEFT JOIN (
    select * from campaign_views where created_at > NOW() - interval '60 days'
  ) views ON views.subscriber_id=subscribers.id 
  WHERE views is null and subscribers.created_at < NOW() - interval '60 days' and status='enabled'
);

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

No branches or pull requests

3 participants