Skip to content

Fix recompute_metrics crash on outcome-window reminders - #68

Merged
tylerrleee merged 1 commit into
mainfrom
fix/outcome-reminder-null-slot
Oct 7, 2026
Merged

tylerrleee merged 1 commit into
mainfrom
fix/outcome-reminder-null-slot

Conversation

@Geaboi

@Geaboi Geaboi commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

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.

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 tylerrleee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to add regression fix on TypeError. LGTM

@tylerrleee
tylerrleee merged commit 6157a52 into main Oct 7, 2026
4 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.

2 participants