'Batching' notifications with setTimeout?

Say I want to send an email after a user makes some changes, but I don’t want to inundate them with emails for every single change. I want to ‘batch’ the notifications, so that some amount of time, say 10 minutes, has to pass before the email is sent.

What’s the best way to do this? Use setTimeout on the server? Will this thread effectively?

I think the best way to do this is to save the notifications to your database, then run a cron job to send them on some kind of interval. I wouldn’t save anything in-memory on your server, since then if your code crashes you’ll lose the notification.

Hm, right… Not sure if there’s a way to do cron jobs on Galaxy :wink:

We actually use this app in Galaxy (the Galaxy frontend app itself, which runs on Galaxy the hosting service): https://github.com/percolatestudio/meteor-synced-cron

(I guess it’s not actively being worked on, but it works really well for us)

Terrific, thank you!

1 Like