Rework org status: remove program status, merged affiliated-since, 3-value status#1993
Rework org status: remove program status, merged affiliated-since, 3-value status#1993maebeale wants to merge 3 commits into
Conversation
| # already-loaded affiliations so a profile can classify many events without an | ||
| # N+1. No facilitator affiliation starting before the date => :new; an earlier | ||
| # one still active on the date => :ongoing; all earlier ones ended => :reinstated. | ||
| def facilitator_status_as_of(date) |
There was a problem hiding this comment.
🤖 From Claude: Deliberately computed in-memory (over the already-loaded affiliations) rather than reusing the DB-backed Organization#facilitator_status_on, so classifying a paginated page of ~9 events doesn't fire 2 queries per event. Same classification rule, just no N+1.
| title: event.title, | ||
| data: { turbo_frame: "_top" }, | ||
| class: "inline-flex items-center rounded-full text-xs font-medium border px-2.5 py-0.5 #{OrganizationDecorator.program_status_classes(status)}" do %> | ||
| <%= status.to_s.titleize %> · <%= event.abbreviation.presence || event.title.truncate(24) %> |
There was a problem hiding this comment.
🤖 From Claude: Falls back to a truncated title when abbreviation is blank so existing events still render a sensible chip. Chips are gated behind manage? to keep program status admin-only, matching how it was treated on the old index column.
06ca55a to
7fb2709
Compare
New/Reinstate/Ongoing can only be determined relative to a specific event, so showing it as a global org attribute was misleading. Per-event program status is surfaced on the org profile in a separate PR (event abbreviations, #1995). - Drop the admin-only "Program" column from the org index. - Drop the now-orphaned Organization.program_statuses_by_id bulk classifier. - Drop the "Program status" block from the org edit form's Affiliations section. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
7fb2709 to
c1bb63c
Compare
Affiliated-since was already affiliation-derived, but showed a single Mon YYYY – Mon YYYY range. Admins need the real shape of an org's history — including gaps — and a status vocabulary that isn't event-specific. - AffiliationPeriods service merges affiliation intervals into periods and formats them as year-based ranges: a lone ongoing period shows "Mon YYYY" (this year) or its start year; multi-period lists are year-only, e.g. "2010-2012, 2026". Falls back to the org's start_date, then blank. - Applied on the org show page, index column, and edit form; the edit form's live preview (affiliation_dates_controller.js) mirrors the same formatting. - Simplify OrganizationStatus to Active / Formerly active / Unknown. Data migration remaps existing statuses (Reinstate->Active, Inactive/Suspended-> Formerly active, Pending->Unknown) then drops the retired records; the affiliation status-sync callback and seeds follow the new names. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| class SimplifyOrganizationStatuses < ActiveRecord::Migration[8.1] | ||
| # Retiring the six-value status set down to Active / Formerly active / Unknown. | ||
| # Each retired status folds into one of the survivors; Reinstate counts as Active. | ||
| RETIRED_TO_REPLACEMENT = { |
There was a problem hiding this comment.
🤖 From Claude: The load-bearing decisions to eyeball: Reinstate folds into Active (per request), Inactive/Suspended into Formerly active, Pending into Unknown. down recreates the retired records but cannot restore per-org mappings — a merge is inherently lossy.
|
|
||
| // Merge affiliation intervals into periods and format them as year-based ranges | ||
| // — the client-side mirror of app/services/affiliation_periods.rb. | ||
| affiliatedSinceLabel(affiliations, today) { |
There was a problem hiding this comment.
🤖 From Claude: This is a hand-kept mirror of AffiliationPeriods (app/services/affiliation_periods.rb) so the edit-form live preview matches the server render. If the Ruby formatting rules change, change both.
…rm's range The affiliation-dates Stimulus controller is shared with the person edit form, whose "Affiliated since" stays a single Mon YYYY range. Gate the merged-periods formatting behind a `periods` value the org form sets, so only the org form's live preview and server render use periods. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🤖 suggested review level: 5 Inspect 🔬 substantive display logic (affiliation-period merging, mirrored in JS) plus a data migration that remaps + drops OrganizationStatus records
What is the goal of this PR and why is this important?
Three related cleanups to org data that only made sense together:
Mon YYYY – Mon YYYYrange.How did you approach the change?
Organization.program_statuses_by_id, and the edit-form "Program status" block.AffiliationPeriodsservice merges affiliation intervals into periods: a lone ongoing period → "Mon YYYY" (this year) or its start year; multi-period lists are year-only →"2010-2012, 2026". Falls back toorg.start_date, then blank. Applied on show / index / edit; the edit form's live JS preview mirrors the same formatting.Reinstate→Active,Inactive/Suspended→Formerly active,Pending→Unknown) then deletes the retired records. The affiliation status-sync callback and seeds follow the new names.Anything else to add?
organization_statussearch filter is kept (real field).