Fix notification queries to exclude tasks from inactive residences

- task_repo.go: Add is_active filter to residence subquery in UserIDs filter
- handler.go: Add is_active filter to daily digest residence join
- onboarding_email_service.go: Fix Django table names and task status filter
- task_repo_test.go: Add regression tests for inactive residence filtering

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Trey t
2025-12-22 14:47:37 -06:00
parent 8cd41a145f
commit 37a04db82e
4 changed files with 124 additions and 12 deletions

View File

@@ -338,9 +338,9 @@ func (h *Handler) HandleDailyDigest(ctx context.Context, task *asynq.Task) error
THEN t.id
END) as due_this_week
FROM auth_user u
JOIN residence_residence r ON r.owner_id = u.id OR r.id IN (
JOIN residence_residence r ON (r.owner_id = u.id OR r.id IN (
SELECT residence_id FROM residence_residence_users WHERE user_id = u.id
)
)) AND r.is_active = true
JOIN task_task t ON t.residence_id = r.id
AND t.is_cancelled = false
AND t.is_archived = false