Skip to content

MFB-717: Phase 1 — Add ScreenCurrentBenefit model and show_in_has_benefits_step#1433

Open
catonph wants to merge 4 commits intomainfrom
caton/mfb-716-migrate-has_-boolean-columns-on-screen-to-a
Open

MFB-717: Phase 1 — Add ScreenCurrentBenefit model and show_in_has_benefits_step#1433
catonph wants to merge 4 commits intomainfrom
caton/mfb-716-migrate-has_-boolean-columns-on-screen-to-a

Conversation

@catonph
Copy link
Contributor

@catonph catonph commented Mar 26, 2026

Context & Motivation

Phase 1 of MFB-716 — purely additive, no behavior change.

The Screen model currently has ~87 has_* boolean columns to track which benefits a user already has. This phase lays the groundwork for migrating to a ScreenCurrentBenefit join table by adding the new model and a show_in_has_benefits_step flag on Program (replacing the static category_benefits white label config). Nothing reads from them yet.

  • Related issue: MFB-716

Changes Made

  • Add ScreenCurrentBenefit join table model to screener/models.py (screen FK + program FK, unique together, db_table = 'screener_screen_current_benefits')
  • Add show_in_has_benefits_step = BooleanField(default=False) to Program model (distinct from show_on_current_benefits)
  • Migrations: programs/0134, screener/0148
  • Expose show_in_has_benefits_step in ProgramAdmin (list_filter + fields) alongside show_on_current_benefits

Testing

  • Migrations to run: 0134_program_show_in_has_benefits_step, 0148_add_screencurrentbenefit
  • Configuration updates needed: none
  • Environment variables/settings to add: none
  • Manual testing steps: confirm screener_screen_current_benefits table is created and show_in_has_benefits_step toggle appears on the Program admin page

Deployment

  • Post-deployment scripts needed: none
  • Production config updates: none
  • Admin updates needed: none
  • Notify team/users of: nothing — no behavior change in this phase

Notes for Reviewers

  • Known limitations: ScreenCurrentBenefit is not yet written to or read from — that comes in Phase 2 (dual-write) and Phase 3 (flip reads)
  • Future considerations: show_in_has_benefits_step will replace the category_benefits white label config in Phase 4; programs will need to be flagged via the admin before that cutover

Summary by CodeRabbit

  • New Features

    • Control which programs appear in the "already has benefits" screener step.
    • Track associations between screens and programs for current-benefits data.
  • Admin Updates

    • New filter and form field in the program administration panel to manage "already has benefits" step visibility.

…efits_step field

- Add ScreenCurrentBenefit join table to screener/models.py
- Add show_in_has_benefits_step BooleanField to Program model
- Write migrations for both (0134, 0148)
- Expose show_in_has_benefits_step in ProgramAdmin (list_filter + fields)
- No changes to serializer, views, or has_benefit() — purely additive

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 26, 2026

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'base_branches'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

Adds a boolean field show_in_has_benefits_step to Program and exposes it in the Django admin; introduces a new CurrentBenefit model linking Screen and Program with a uniqueness constraint; includes corresponding migrations.

Changes

Cohort / File(s) Summary
Program model + admin
programs/models.py, programs/migrations/0134_program_show_in_has_benefits_step.py, programs/admin.py
Added Program.show_in_has_benefits_step: BooleanField(default=False, help_text=...); migration to add the field; updated ProgramAdmin.list_filter and fields to include the new field.
Screener CurrentBenefit model
screener/models.py, screener/migrations/0148_add_currentbenefit.py
Added CurrentBenefit model with screen (FK to screener.Screen, related_name="current_benefits") and program (FK to programs.Program); DB table set to screener_current_benefits and (screen, program) uniqueness constraint; migration added with cross-app dependency.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: adding a ScreenCurrentBenefit model and show_in_has_benefits_step field, matching the changeset scope.
Description check ✅ Passed The PR description includes all required sections: context, changes, testing, deployment, and reviewer notes. It thoroughly documents the additive Phase 1 work with clear limitations and future considerations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch caton/mfb-716-migrate-has_-boolean-columns-on-screen-to-a

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@catonph catonph changed the title MFB-716: Phase 1 — Add ScreenCurrentBenefit model and show_in_has_benefits_step MFB-717: Phase 1 — Add ScreenCurrentBenefit model and show_in_has_benefits_step Mar 26, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
screener/migrations/0148_add_currentbenefit.py (1)

37-40: Consider UniqueConstraint for future migrations.

While unique_together is still functional in Django 4.2, it's deprecated in favor of using constraints with UniqueConstraint. Since this is Phase 1 and the model definition also uses unique_together, this is fine for now. Consider modernizing both the model and future migrations when convenient.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@screener/migrations/0148_add_currentbenefit.py` around lines 37 - 40, The
migration uses migrations.AlterUniqueTogether on the "currentbenefit" model with
unique_together={("screen", "program")}; replace this with a
UniqueConstraint-based approach for future migrations by adding a
migrations.AddConstraint (or migrations.AlterModelOptions with constraints) that
creates models.UniqueConstraint(fields=["screen", "program"],
name="unique_currentbenefit_screen_program") and remove the AlterUniqueTogether
entry; update the corresponding model's Meta to use constraints =
[models.UniqueConstraint(...)] so code and migrations stay in sync.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@screener/migrations/0148_add_currentbenefit.py`:
- Around line 37-40: The migration uses migrations.AlterUniqueTogether on the
"currentbenefit" model with unique_together={("screen", "program")}; replace
this with a UniqueConstraint-based approach for future migrations by adding a
migrations.AddConstraint (or migrations.AlterModelOptions with constraints) that
creates models.UniqueConstraint(fields=["screen", "program"],
name="unique_currentbenefit_screen_program") and remove the AlterUniqueTogether
entry; update the corresponding model's Meta to use constraints =
[models.UniqueConstraint(...)] so code and migrations stay in sync.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: MyFriendBen/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f7cdc244-90ba-4e64-ae08-df03badc7c1b

📥 Commits

Reviewing files that changed from the base of the PR and between a20c89b and e48d255.

📒 Files selected for processing (4)
  • programs/migrations/0134_program_show_in_has_benefits_step.py
  • programs/models.py
  • screener/migrations/0148_add_currentbenefit.py
  • screener/models.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • programs/models.py
  • screener/models.py

@catonph catonph requested a review from patwey March 26, 2026 20:29
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@screener/migrations/0148_add_currentbenefit.py`:
- Around line 33-35: The migration sets options["db_table"] to
"screener_current_benefits" which conflicts with the rollout contract expecting
"screener_screen_current_benefits"; update the db_table value in the migration
(file/migration name 0148_add_currentbenefit.py) to
"screener_screen_current_benefits" and ensure any references in this migration
(e.g., the model's Meta options or CreateModel call) use that exact table name
so Phase 2/manual verification and runbooks align with the deployment notes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: MyFriendBen/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 44b58e76-3044-43e9-9f45-6f0bb9204213

📥 Commits

Reviewing files that changed from the base of the PR and between e48d255 and cd921f1.

📒 Files selected for processing (2)
  • programs/migrations/0134_program_show_in_has_benefits_step.py
  • screener/migrations/0148_add_currentbenefit.py

Comment on lines +33 to +35
options={
"db_table": "screener_current_benefits",
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

db_table name appears inconsistent with rollout contract.

The migration creates screener_current_benefits, but the PR objective/deployment notes expect screener_screen_current_benefits. This can break Phase 2+/manual verification if other code or runbooks key off the expected table name.

Proposed fix
             options={
-                "db_table": "screener_current_benefits",
+                "db_table": "screener_screen_current_benefits",
             },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
options={
"db_table": "screener_current_benefits",
},
options={
"db_table": "screener_screen_current_benefits",
},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@screener/migrations/0148_add_currentbenefit.py` around lines 33 - 35, The
migration sets options["db_table"] to "screener_current_benefits" which
conflicts with the rollout contract expecting
"screener_screen_current_benefits"; update the db_table value in the migration
(file/migration name 0148_add_currentbenefit.py) to
"screener_screen_current_benefits" and ensure any references in this migration
(e.g., the model's Meta options or CreateModel call) use that exact table name
so Phase 2/manual verification and runbooks align with the deployment notes.

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.

1 participant