Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion analytics/analysis-resources/data-dictionary.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ participant has an active JITAI outcome window open. Confirmed by Dr. Chang, 202
| `id` | INT (PK) | Backend / scheduler | Primary key. |
| `user_id` | INT (FK → `user.user_id`) | Backend / scheduler | Participant who received the reminder. |
| `sent_at` | DATETIME | Backend / scheduler | When the reminder push was sent (`auto_now_add`). |
| `daily_count_at_send` | SMALLINT | Backend / scheduler | **The 0-indexed check-in slot this reminder was for** (0–5). Despite the column name it is not a count of anything. |
| `daily_count_at_send` | SMALLINT, nullable | Backend / scheduler | **The 0-indexed check-in slot this reminder was for** (0–5). Despite the column name it is not a count of anything. **NULL for an outcome-window reminder** (migration `0050`), which is tied to a decision point through `jitai_log_id` instead of a slot; filter on `IS NOT NULL` before treating the value as a slot index. |

> **Corrected 2026-09-10.** Earlier revisions described `daily_count_at_send` as the number of
> check-ins already submitted that day, and the task as enforcing a 120-minute cooldown. Both
Expand Down
3 changes: 2 additions & 1 deletion analytics/analysis-resources/production_schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ Note: unique/index names on this table are still prefixed `app_wearabledevice_fi
|---|---|---|---|
| id | bigint | not null | identity |
| sent_at | timestamptz | not null | |
| daily_count_at_send | smallint | not null | |
| daily_count_at_send | smallint | null | |
| jitai_log_id | bigint | null | |
| user_id | integer | not null | |

**PK:** id  ·  **Index:** user_id  ·  **Checks:** daily_count_at_send >= 0
Expand Down
3 changes: 2 additions & 1 deletion dashboard/data/daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ def _ema_metrics(user, local_date, day_start, day_end, slots):

reminders = list(
CheckinReminder.objects
.filter(user=user, sent_at__gte=day_start, sent_at__lt=day_end)
.filter(user=user, sent_at__gte=day_start, sent_at__lt=day_end,
daily_count_at_send__isnull=False)
.values_list('daily_count_at_send', 'sent_at')
)
reminded = {}
Expand Down
8 changes: 8 additions & 0 deletions dashboard/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ def test_payload_covers_every_model_column(self):
keys = {'study_day', 'local_date', 'is_run_in', 'is_active_day', 'item_bank_version'}
self.assertEqual(model_fields, set(METRIC_FIELDS) | keys)

def test_outcome_reminder_without_slot_is_excluded_from_slot_metrics(self):
make_reminder(self.user, 2, self._at(13, 0))
make_reminder(self.user, None, self._at(15, 0))

metrics = self._compute()
self.assertEqual(metrics['slots_reminded_uncovered'], 1)
self.assertEqual(metrics['reminders_sent'], 1)

def test_slot_coverage_and_reminders(self):
make_ema(self.user, self._at(10, 15), answers={'B1_valence': 5})
make_ema(self.user, self._at(13, 30), answers={'B1_valence': 3})
Expand Down
Loading