rubyforgood / rubyforgood/awbw
Backfill contact_us_fyi communications as incoming, then drop the dual-condition checks
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 15
- Forks
- 26
- Avg merge
- 12h 42m
- Merged PRs (30d)
- 242
Description
Context
In #2239 we extended the "needs response" concept from contact_us_fyi notifications to all incoming communications. Because existing contact_us_fyi rows are stored as direction: "outgoing", the code currently has to check both conditions:
Notification#requires_response?—kind == "contact_us_fyi" || incoming?Notification.responded_statusscope —where(kind: "contact_us_fyi").or(where(direction: "incoming")), and the"na"branch has to exclude both.
A contact_us_fyi is conceptually an incoming contact (the person reached out to us), so it should simply carry direction: "incoming". Once it does, the kind == "contact_us_fyi" half of every check is redundant and can go.
Work
- Create new
contact_us_fyinotifications as incoming. Update wherever they're generated (contact-form flow /NotificationServices) sodirection: "incoming"is set on creation. Do this first — otherwise removing the OR breaks newly-created rows. - Backfill existing rows — a reversible data migration:
Notification.where(kind: "contact_us_fyi", direction: "outgoing").update_all(direction: "incoming")(guard thedown). - Simplify the code once every
contact_us_fyiis incoming:requires_response?→incoming?responded_status→ key offdirection: "incoming"only:"yes"→where(direction: "incoming", responded: true)"no"→where(direction: "incoming", responded: false)"na"→where.not(direction: "incoming")
- Update specs in
spec/models/notification_spec.rb(the.responded_statusand#requires_response?groups) to reflect the single-condition logic.
Notes
- Sanity-check that no
contact_us_fyishould legitimately be outgoing before backfilling. - Files:
app/models/notification.rb, plus the contact-form/notification-creation path.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with app/models/notification.rb, the contact-form/NotificationServices creation path, and the .responded_status and #requires_response? specs in spec/models/notification_spec.rb. Add the reversible backfill migration after confirming contact_us_fyi rows should be incoming, update creation and conditions, then run the notification specs and verify the migration’s down path is guarded.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend, databases
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100