Skip to content

feat(invitations): carry chapter_id and workshop_date in invitation job log lines - #2988

Merged
mroderick merged 1 commit into
codebar:masterfrom
mroderick:invitation-log-context
Oct 7, 2026
Merged

mroderick merged 1 commit into
codebar:masterfrom
mroderick:invitation-log-context

Conversation

@mroderick

@mroderick mroderick commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Workshop invitation emails (invite_student and invite_coach) are sent as individual ActionMailer::MailDeliveryJob jobs. The canonical job log lines (enqueue, perform_start, perform) carry the serialized job arguments, which today contain only Workshop, Member and WorkshopInvitation gids. Nothing connects an invitation email to its chapter, so log-based tooling cannot attribute invitation volume to chapters without a second data source.

This adds an optional trailing log_context argument to WorkshopInvitationMailer and VirtualWorkshopInvitationMailer#invite_student / #invite_coach. The batch code in InvitationManager passes { chapter_id, workshop_date } (UTC date). Both values are plain attributes on the workshop record the caller already holds, so this introduces no additional database queries. The hash is serialized as part of the job arguments and therefore appears in every canonical log line for the job.

Other callers are unaffected; the parameter defaults to empty.

  • send_workshop_emails and send_virtual_workshop_emails batch paths pass the context
  • attending, attending_reminder, waiting_list and event invitation mailers are intentionally out of scope
Details
  • invitation_log_context in InvitationManager#private builds the hash with safe navigation for workshops without a date
  • specs: shared example asserts both mailer methods receive the exact context, and runs a real Delayed::Job enqueue (delay_jobs on) to prove the context survives the serialize/deserialize round trip; mailer specs assert the optional argument does not break delivery
  • full suite: 1629 examples, 0 failures (re-run green twice)

Review notes

  • Scope: only invite_student/invite_coach get context. attending, reminders and waiting-list lines stay as they are. Say so if those should be covered too.
  • The extra serialized argument slightly grows job data (delayed_jobs handler and log volume); it is two small values per email.
  • The chapter name is deliberately not logged, only the id.

@mroderick
mroderick force-pushed the invitation-log-context branch from 39a349c to e04fadb Compare October 7, 2026 09:14
mroderick added a commit to mroderick/codebar-planner that referenced this pull request Oct 7, 2026
Review fix for PR codebar#2988. The specs only asserted that the mailer methods accept the log_context argument; nothing exercised the YAML serialize/deserialize round-trip through Delayed::Job that the canonical job log lines depend on. Test env delivers inline (Delayed::Worker.delay_jobs = false), so that path was never exercised.

The new shared example flips delay_jobs on for the duration of the example (restored in ensure), sends through the real deliver_later path, and asserts the deserialized fourth mailer argument equals the log_context hash.
@mroderick
mroderick force-pushed the invitation-log-context branch from e04fadb to 0cc7da6 Compare October 7, 2026 09:24
…ob log lines

Workshop invitation emails are sent as individual ActionMailer jobs, and the canonical job log lines (enqueue, perform_start, perform) only carried Workshop, Member and WorkshopInvitation gids. Nothing tied the emails to the workshop chapter, so log-based tooling could not attribute invitation volume to chapters without a second data source.

The batch code already holds the workshop record, so the chapter id and the workshop date (UTC) ride along as an optional trailing log_context argument on WorkshopInvitationMailer and VirtualWorkshopInvitationMailer invite_student/invite_coach. They end up serialized in the job arguments, which the job log lines already emit. No additional database queries: the values are plain attributes on the workshop record the caller has loaded.

A shared example pins the serialize/deserialize round-trip of log_context through delayed_job. Other callers are unaffected; the parameter defaults to empty.
@mroderick
mroderick force-pushed the invitation-log-context branch from 0cc7da6 to f401945 Compare October 7, 2026 09:29
@mroderick
mroderick marked this pull request as ready for review October 7, 2026 09:32
@mroderick
mroderick requested a review from olleolleolle October 7, 2026 09:33
@mroderick
mroderick merged commit 823dc9c into codebar:master Oct 7, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant