rubyforgood / rubyforgood/awbw
Backfill facilitator affiliation start dates from legacy member_since
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 15
- Forks
- 26
- Avg merge
- 12h 42m
- Merged PRs (30d)
- 242
Description
Problem
Facilitator start dates now come from affiliation records, but the profile/decorator still falls back to the legacy member_since column when a Facilitator affiliation has no start_date:
PersonDecorator#facilitator_since_date→affiliations.facilitators.minimum(:start_date) || member_since(app/decorators/person_decorator.rb).
So where a facilitator's affiliations are missing start dates, the displayed "Facilitator since" is driven by member_since rather than the affiliation data. The edit form already flags the mismatch (member_since_earlier_than_facilitator_affiliations? / member_since_differs_from_facilitator_affiliations?), which shows these two sources disagree in production data.
The result: the affiliation records and the profile displays can be out of sync, and the "Affiliated since" grey note (added in #2280) only reads correctly once affiliation dates are trustworthy.
Goal
Make the affiliation data the single source of truth so member_since is no longer needed as a fallback for facilitators.
Scope / questions to settle
- Backfill direction: for facilitators whose
Facilitatoraffiliation(s) have a blankstart_date, populate it frommember_since(the earliest sensible value). - Conflicts: decide what to do when
member_sinceis earlier than or differs from an existing affiliation start date — earlier likely means an affiliation record is missing that stretch; a plain difference may just be legacy noise. Don't clobber real affiliation start dates. - Idempotent migration/rake task with a dry-run report of what would change (counts of: blank→filled, member_since earlier than all facilitator affiliations, member_since differs), reviewable before running against prod.
- After backfill: confirm the
member_sincefallback infacilitator_since_datecan be removed (or is only hit by legacy edge cases), and drop the form warnings once the data is clean.
Notes
- Related display work: #2280 (affiliated-since grey note).
- Same pattern likely applies to org-level program dates (
OrganizationDecorator#program_since_date) and the orgstart_datefallback — worth checking in the same pass.
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/decorators/person_decorator.rb and the facilitator_since_date fallback, then review the affiliation start-date checks named in the issue. Define the conflict handling and inspect the related organization fallback before implementing an idempotent migration or rake task with a dry-run report. Done means missing dates are backfilled without clobbering existing dates, the report is reviewable, and the fallback and warnings are reassessed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend, database
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100