we're using 'whenever' schedule jobs in rails project. system expanding support users in multiple timezones (timezone stored in user model) , send users email @ specific time of day.
any ideas on best pattern achieve this? i'm foreseeing 24 (or more - there half timezones) 'whenever' tasks per email job each different timezone filter on user table.
any ideas cleaner solution? better scheduler whenever perhaps? create 24/48 cronjobs , call callback passing timezone or utc offset? that.
i not familiar 'whenever' had similar challenge , used clockwork
my problem had run process @ midnight each of customers. , you, customers can anywhere in world had ran @ midnight time.
the process of running job @ midnight looked this:
tzinfo::timezone.all_country_zone_identifiers.each |zone| every(1.day, {time_zone: zone}, at: '00:00', tz: "#{zone}") |job_attr| time_zone = job_attr[:time_zone] yourjob.perform_later(time_zone) end end
the class of 'yourjob' find customers time_zone , perform job.
hope helps.
Comments
Post a Comment