action-scheduler icon indicating copy to clipboard operation
action-scheduler copied to clipboard

fix: parsing of day of week when `#` used

Open shohag121 opened this issue 4 years ago • 4 comments
trafficstars

Currently, we only can use 1 to 5 as a "day of week" when we use # sign with it.

In this PR, Day of week range check is set to 0 to 7. it fixes the parsing of string with # sign. eg. 0 12 ? 1/1 SUN#2 *

fix: https://github.com/woocommerce/action-scheduler/issues/781

shohag121 avatar Oct 22 '21 04:10 shohag121

Hi @barryhughes,

Would you kindly review this PR and let me know if any additional change is needed?

Thanks.

shohag121 avatar Jan 10 '22 07:01 shohag121

Sorry for the delay here, @shohag121. Testing this out:

Expression Before fix After fix
⛔️ 0 12 ? 1/1 SUN#2 * Must be a value between 1 and 5 Impossible CRON expression
⛔️ 0 12 * * SUN#2 Must be a value between 1 and 5 Impossible CRON expression
0 12 * * SAT#2 Must be a value between 1 and 5 (Works!)
0 12 * * MON#2 (Works!) (Works!)

It looks like:

  • In the first two cases (using Sunday), the exception you noted is solved but we hit a different problem (impossible CRON expression)
  • In the third case (using Saturday), the exception you noted is solved and there is no further issue
  • In the final case (using Monday - Friday), there is no change

Do you find the same? It does look like this yields an incremental improvement—as demonstrated by the third scenario—but some further work is needed to fully smooth things out. Ideally, we would also add some further test cases to ActionScheduler_CronSchedule_Test (and we could help with that if needed).

barryhughes avatar Jan 10 '22 19:01 barryhughes

📝 Note to self: so far as I can tell, this lib is a custom fork that lives directly within our repo (ie, it is likely fine to adjust directly).

barryhughes avatar Jan 10 '22 19:01 barryhughes

so far as I can tell, this lib is a custom fork that lives directly within our repo (ie, it is likely fine to adjust directly).

It is to both.

rrennick avatar Jan 11 '22 16:01 rrennick