Fork me on GitHub
#biff
<
2023-10-03
>
Luciano Laratelli20:10:16

Am I holding the scheduled tasks wrong? I’m seeing them fire when my app starts even when it isn’t the scheduled time. think_beret Here’s my schedule and plugin:

(defn report-schedule []
  (let [desired-hour 15
        hour-in-eastern-time  (-> (LocalTime/of desired-hour 0 0)
                                  (.adjustInto (ZonedDateTime/now (ZoneId/of "America/New_York")))
                                  .toInstant)
        every-day-at-hour (chime/periodic-seq  hour-in-eastern-time (Period/ofDays 1))
        every-weekday-at-hour (->> every-day-at-hour
                                   (map #(.atZone % (ZoneId/of "America/New_York")))
                                   (remove (comp #{DayOfWeek/SATURDAY DayOfWeek/SUNDAY}
                                                 #(.getDayOfWeek %))))]
    every-weekday-at-hour))

(def plugin
  {:tasks [{:task #'report-runner
            :schedule report-schedule}]})

Jacob O'Bryant21:10:35

if the first scheduled time occurs before the current time, it'll get triggered immediately. maybe check (first (report-schedule))?

Luciano Laratelli21:10:57

That’s what it was. Thanks Jacob!

🙌 1