Reputation: 7043
I am giving users an option to receive, say, emails at a periodicity of their choice, for example:
Every day at 5am
or
Every Friday at 11pm
or even
Every second Monday of the month at 12am
What would be my best choice for storing this kind of data in order to feed it to Whenever
gem?
Update
I was able to solve the question with @mudasobwa 's advice in combination with the cron_parser
gem. The process flow is:
7
would mean that I will need to send emails every week, so the code could be "1 1 * * 1
"), store the value as periodicity
.cron_parser
gem to generate the next_run
dateformat which is used to tell whenever gem which jobs it needs to perform that are dated. Upvotes: 1
Views: 114
Reputation: 121000
whenever
gem accepts a raw cron syntax. That is why the simplest way, involving as few transformations as possible, would be to store values in raw cron format.
That said, you probably should have a parser from/to allowed user input to/from raw cron format and that’s it.
Upvotes: 2