Repository navigation
feat(notifications): show leave in the coordinators' morning e-mail - #404
Merged
Merged
Conversation
A duty whose holder has a leave entry on its day is one nobody took over.
The digest marks it on the role line ("na urlopie, bez zastępstwa"), asks
for the change in one sentence when it is one of today's duties, names who
is on leave today with the last day of the leave, and lists the duties of
people on leave in the seven days ahead. Without leave it reads as before.
The digest reads leave through the calendar's own leave runs, now a method
of the member, and the template takes the digest itself.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Intent
The oncall project gained a new preference kind "U" (urlop, leave). The captain approved a 5-step plan; steps 1-4 (PRs 399, 400, 401, 403) are merged. This is the LAST STEP 5: the morning e-mail of the coordinators (T5, D10-A) says it where the duty is read: the role line, one action sentence, "Na urlopie" and the week ahead. The approved design and decisions are in ~/firstmate/data/oncall-leave-u-scout/report.md (section 4.5 T5 paragraph at line ~146, D10, 6.2 step 5, 9, 11), critique evidence in data/oncall-leave-u-scout/critique/. Leave is team-visible only as "urlop", never with a reason or note (D14).
What those report items say, so this stands without the report:
What Changed
leave_runsfunction.Risk Assessment
✅ Low: The change only adds read-only content to an existing e-mail that still goes to coordinators and admins only; the round 1 fix now reads just current or future leave entries without notes, one rule for joining entries is shared with the calendar, and the output matches every required T5/D10-A sentence.
Testing
I ran the real app and worker against a throwaway PostgreSQL database and a local test mail server, and read the e-mails that arrived. The example from the intent matched word for word. With nobody on leave, the e-mail was identical to the one from the base commit. Weekends, duties taken over by someone else, the seven-day limit, private notes, people who left the team and days off all passed, and so did the related test files. I ran those tests with the project's Python because the installed uv is 0.12.22 and the project requires 0.13.10. Early runs failed because of my test setup: the mail server stalled on name lookups, and some script queries and expectations were wrong. I fixed these in the test scripts and reran every scenario; no product code changed. The logo is broken in the screenshots only because its web address was not being served. Screenshots, e-mail copies and a transcript are saved, and everything temporary was removed.
Evidence: Received example e-mail as plain text
Evidence: Transcript of all scenarios
Evidence: Scenario script (uses drive.py and run_at.py beside it)
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
backend/src/oncall/domain/digest.py:103- The new member read is heavy and runs on every worker poll, even after the digest has been sent.notification_cyclecallsscan_digesteveryworker_poll_seconds(5 s by default, config.py:201). From hour 8 to midnight on a working day,send_daily_digestbuilds the full digest each time. Duplicates are dropped only later, bydedup_keyinenqueue_duty_digest, and the 'no SMTP host' exit (triggers.py:937) also comes after the build. Before this change the only read wasduties_in_force, which has a short cache on PostgreSQL. Nowmembers_for_range(infrastructure/sqlalchemy/calendar.py:116) also runs. It has no date filter on availability, loads every kind of entry ever written with its notes, and joins two collections (availability x eligibility), so rows multiply. Example: 20 people x 200 entries x 3 eligibility periods = 12,000 joined ORM rows every 5 s for 16 hours, on the event loop the worker's other tasks share. It grows for ever, because availability entries are kept. Smallest fix: giveDigestTeama narrow read that returns only leave entries withends_on >= working_day(later adjacent entries are still needed to join a run), without eligibility, notes or authors.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
alembic upgrade headon an empty, throwaway PostgreSQL 18.7 container.venv/bin/python drive script scenarios.py <pg> <smtp> <web> <base src>: leave and duty changes went in through the real HTTP API, and the real worker sent the e-mails to a local Mailpit server. The product's clock was set to 10, 11 and 12 December 2026 (and 8 December for entering some leave)Ran the base commit 81a93d5 worker and the new worker on copies of the same database with no leave, then compared the e-mailsLooked at Chromium screenshots of the received HTML e-mails at 760 px and 500 px wide.venv/bin/python -m pytest -q tests/test_digest.py tests/test_digest_leave_entries.py tests/test_email_templates.py tests/architecture/test_language.py(exit 0)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.