Repository navigation
Fix recompute_metrics crash on outcome-window reminders - #68
Merged
Merged
Conversation
recompute_monitoring_metrics failed with "TypeError: '<=' not supported between instances of 'int' and 'NoneType'" in dashboard/data/daily.py _ema_metrics, so no MetricsDaily rows were written for any participant-day that contained an outcome reminder. What went wrong: - Migration 0050 (2026-09-29) made CheckinReminder.daily_count_at_send nullable and added jitai_log. The +60 min outcome check-in reminder (tasks.py) is saved with a jitai_log and no slot, so the column is NULL. - _ema_metrics treated every CheckinReminder as a slot reminder and ran 0 <= index < SCHEDULED_CHECK_IN_DAILY_CAP on the value. The first outcome reminder of a day raised the TypeError and aborted the recompute. - The schema docs still described the column as not null, and the metrics reader was not updated when the writer changed. Fix: _ema_metrics reads only reminders with a slot (daily_count_at_send__isnull=False). Outcome reminders no longer count toward slots_reminded_uncovered, slots_silent or reminders_sent, which describe the slot schedule. The timeline view is unaffected: a NULL slot matches nothing there. Adds a regression test and corrects production_schema.md and data-dictionary.md. After deploy, run `manage.py recompute_metrics --all` to backfill days missed since 2026-09-29; the periodic task only covers the trailing 3 days.
tylerrleee
approved these changes
Oct 7, 2026
tylerrleee
left a comment
Collaborator
There was a problem hiding this comment.
Good to add regression fix on TypeError. LGTM
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.
recompute_monitoring_metrics failed with "TypeError: '<=' not supported between instances of 'int' and 'NoneType'" in dashboard/data/daily.py _ema_metrics, so no MetricsDaily rows were written for any participant-day that contained an outcome reminder.
What went wrong:
Fix: _ema_metrics reads only reminders with a slot (daily_count_at_send__isnull=False). Outcome reminders no longer count toward slots_reminded_uncovered, slots_silent or reminders_sent, which describe the slot schedule. The timeline view is unaffected: a NULL slot matches nothing there.
Adds a regression test and corrects production_schema.md and data-dictionary.md.
After deploy, run
manage.py recompute_metrics --allto backfill days missed since 2026-09-29; the periodic task only covers the trailing 3 days.