Fix newsletter trigger semantics, Monday roundup gating, roundup idempotency, and website-order section rendering#455
Conversation
|
@copilot waiting until all roundups have the same date epoch won't work I think, you need to check if they all have a date matching the last Monday, or current Monday if triggered on a Monday |
Updated in commit |
|
@copilot with our periodic jobs, how do we make sure we don't send out a newsletter for the same roundups twice? And I think when I tested a roundup email I saw in the send log in the admin screens rows appear for each section. I just want love row for the roundup email (it's only one email after all) and one for a daily email |
Addressed in
|
|
@copilot tests fail |
Fixed in |
⏰ PR Preview Environment — Nightly TeardownThe preview environment was automatically torn down as part of the nightly cleanup (23:00 Brussels time). To resume testing:
|
There was a problem hiding this comment.
Pull request overview
This PR refines newsletter sending semantics across the API, background worker, infrastructure service, web client, admin UI, and tests. It separates roundup vs daily manual triggers, gates roundup dispatch by the expected Brussels-time Monday cycle, and aligns email section ordering with configured website order.
Changes:
- Added
kind-based newsletter triggering for roundup and daily sends across admin/API/client/background paths. - Updated weekly roundup sending to use Monday cycle keys for idempotency and single-row send logging.
- Added ordering helpers/tests so weekly and daily email sections render in configured website order.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/TechHub.Api/Endpoints/NewsletterEndpoints.cs |
Accepts and normalizes trigger kind, then forwards it to the background service. |
src/TechHub.Api/Services/NewsletterBackgroundService.cs |
Routes manual daily vs roundup sends and gates roundup sends to the expected Monday cycle. |
src/TechHub.Core/Interfaces/INewsletterService.cs |
Extends combined weekly sending with an optional send target key. |
src/TechHub.Infrastructure/Services/Newsletter/NewsletterService.cs |
Implements cycle-key idempotency, single-row roundup logging, and section ordering helpers. |
src/TechHub.Web/Services/ITechHubApiClient.cs |
Updates the newsletter trigger client contract to accept a trigger kind. |
src/TechHub.Web/Services/TechHubApiClient.cs |
Normalizes trigger kind and includes it in the admin trigger request. |
src/TechHub.Web/Components/Pages/Admin/AdminNewsletter.razor |
Splits the admin trigger into explicit Send Roundup and Send Daily actions. |
tests/TechHub.Api.Tests/Endpoints/NewsletterEndpointsTests.cs |
Adds endpoint coverage for daily triggering and Monday-gated roundup behavior. |
tests/TechHub.Infrastructure.Tests/Services/NewsletterServiceTests.cs |
Updates weekly send-log expectations and adds email ordering coverage. |
tests/TechHub.Web.Tests/Services/TechHubApiClientTests.cs |
Verifies trigger kind normalization and query construction. |
Newsletter sending had two gaps: admin “Send Newsletter” only triggered roundup flow, and roundup dispatch could run at the wrong cycle boundary. This change separates manual trigger modes (roundup vs daily), gates roundup sends to the expected Monday cycle, normalizes section ordering in emails to match website order, and ensures roundup sends are idempotent per cycle with a single send-log row.
Manual trigger modes (admin/API)
kindsupport to newsletter trigger (roundupdefault,dailyoptional).Roundup timing gate
(slug, date_epoch).Roundup idempotency + send-log granularity
yyyy-MM-dd) instead of per-section slug.Section ordering in email content
NewsletterServiceto sort sections/roundups by configured website section order (AppSettings.Content.Sections[*].Order).Focused test updates