ucsb-cs156-m23 / proj-happycows-m23-10am-3

https://ucsb-cs156-m23.github.io/proj-happycows-m23-10am-3/
0 stars 0 forks source link

BUG: Milk at 4am PST or GMT? #7

Closed github-actions[bot] closed 1 year ago

github-actions[bot] commented 1 year ago

Summary

The text on the website says the cows are milked at 4am.

However, the cron expressions in the ScheduledJobs class are, by default, expressed in Zulu time (i.e. Coordinated Universal Time, aka Greenwich Mean Time).

We would prefer that to be in local time.

Expected Behavior

It should be 4am local time

Current / Observed Behavior

It isn't

Steps to Reproduce

Look at the logs to see when the job actually ran.

Implementation Notes

As explained here it's possible to include a timezone in the @Scheduled annotations. The example given is:

@Scheduled(cron = "0 15 10 15 * ?", zone = "Europe/Paris")

The zone we want is this one: America/Los_Angeles

http://www.timezoneconverter.com/cgi-bin/zoneinfo?tz=America/Los_Angeles

It's ok to hard code it for now. If we ever need to support another timezone, we can make this a configuration variable like the cron expressions are.

To test

Check the logs for the scheduled jobs and see when they run. If necessary, you can override the default schedule with configuration variables. See the src/main/resources/application.properties file where you'll find expressions like these:

app.updateCowHealth.cron=${UPDATE_COW_HEALTH_CRON:${env.UPDATE_COW_HEALTH_CRON:0 0 0,12 * * *}}
app.milkTheCows.cron=${MILK_THE_COWS_CRON:${env.MILK_THE_COWS_CRON:0 0 4 * * *}}

and the corresponding entries in src/main/resources/application-development.properties

app.updateCowHealth.cron=${UPDATE_COW_HEALTH_CRON:${env.UPDATE_COW_HEALTH_CRON:0 */7 * * * *}}
app.milkTheCows.cron=${MILK_THE_COWS_CRON:${env.MILK_THE_COWS_CRON:0 */13 * * * *}}

For an explanation of the syntax 0 */13 * * * * or 0 0 0,12 * * * see https://spring.io/blog/2020/11/10/new-in-spring-5-3-improved-cron-expressions