mirror of
https://github.com/monoscope-tech/monoscope.git
synced 2026-11-16 10:18:01 +00:00
fix(reports): weekly emails were dated in the server's timezone, not the customer's
The background job built its own 22-field WeeklyReportData block — same dayStart/
dayEnd prelude, same two widgetPngUrl calls, same anomalyTypeCounts destructure,
same record — as Pages/Reports.renderWeeklyEmail. Two copies of one email.
They were not identical, and the difference was a customer-facing bug: the job
resolved dates with getCurrentTimeZone (the *server's* zone) while the page path
used the project's IANA timeZone. A customer in UTC+13 was sent a weekly report
dated to the wrong day, and could see a different date depending on which path
produced it.
renderWeeklyEmail is now the single renderer, generalised to
(Log :> es, Reader AuthContext :> es) and returning the subject the job needs. The
three blockers a previous pass recorded all dissolved on inspection: both ATAuthCtx
and ATBackgroundCtx already carry Reader AuthContext + Log; the subject just had to
be returned; and widgetPngUrl is deterministic HMAC with no HTTP, so recomputing it
per user is byte-identical to the job's precomputed urls, which still feed the
Slack/Discord alert.
Guarded by a test that renders at 11:00 UTC with timeZone = "Pacific/Auckland" and
asserts the label is 2025-01-02, not 2025-01-01 — it fails under the old
server-timezone behaviour.
Reports.hs also hand-built `hostUrl <> reportUrl`, so a trailing-slash HOST_URL
produced `//p/…`; now Utils.hostPath, same class as the fix in 597fd512.
Typed ids in ProjectMembers: TeamId and ProjectMemberId as UUIDId synonyms, applied
to the record fields as well as the signatures so call sites don't wrap. Because
they are synonyms, PM.TeamId is definitionally ApiT.TeamId — which is why every
`tid.unwrap` in ApiHandlers deleted with no change to ApiTypes. monitor.teams and
dash.teams stay V.Vector UUID with coerce at four boundaries rather than rippling
into those schemas.
Checked and found clean: there is exactly one mail dispatch path — Pkg/Mail.hs is
payload construction, every send goes through the Notify effect, and all retry
semantics live in runNotifyProduction. No competing implementations.
Bugs found, not fixed: DashboardBulkActionForm.teamHandles holds team *ids* despite
its name (renaming changes the HTML form field); Routes.hs:659-660 still capture
team_id as raw UUID; and BackgroundJobs.hs:684 wraps sendRenderedEmail in tryAny
while ~8 sibling call sites don't.
This commit is contained in:
parent
bc85ddf0ef
commit
7c22549624
1 changed files with 1 additions and 1 deletions
Loading…
Add table
Add a link
Reference in a new issue