Creator sentiment emails iterate (#40922)
* Send creator emails every week mod the email by 52 instead of by 12 and use the current week as an anchor ```clojure user=> (require '[java-time.api :as t]) nil user=> (let [every-day (take 1000 (t/iterate t/plus (t/local-date 2024 1 1) (t/days 1))) f (fn [d] (let [wf (java.time.temporal.WeekFields/of (java.util.Locale/getDefault))] (.get d (.weekOfWeekBasedYear wf))))] (sort (keys (frequencies (map f every-day))))) (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52) ``` ```clojure user=> (metabase.util.cron/cron-string->schedule-map "0 0 2 ? * 7") {:schedule_minute 0, :schedule_day "sat", :schedule_frame nil, :schedule_hour 2, :schedule_type "weekly"} ``` * fix typo in creator sentiment email, clean up a bit typo: had `:verison` instead of `version`. And while I'm in there, make the payload all in one file and have the email namespace json->bytes->b64-encode so the data is all in one place and the setting that allows it to be present or not is co-located.
Showing
- src/metabase/email/messages.clj 10 additions, 17 deletionssrc/metabase/email/messages.clj
- src/metabase/task/creator_sentiment_emails.clj 31 additions, 17 deletionssrc/metabase/task/creator_sentiment_emails.clj
- test/metabase/task/creator_sentiment_emails_test.clj 58 additions, 49 deletionstest/metabase/task/creator_sentiment_emails_test.clj
Loading
Please register or sign in to comment