Skip to content

HOLD: Replace org-index windows-type filter/column with age-range filter#1927

Draft
maebeale wants to merge 1 commit into
mainfrom
maebeale/age-range-filter-windows-type
Draft

HOLD: Replace org-index windows-type filter/column with age-range filter#1927
maebeale wants to merge 1 commit into
mainfrom
maebeale/age-range-filter-windows-type

Conversation

@maebeale

Copy link
Copy Markdown
Collaborator

🤖 PR, suggested 👤 review level: 📖 Read — light-logic: a new filter scope + a display fallback, contained to the organizations index

What & why

Age-range category tags now carry audience info on the organizations index, making the separate windows-type column and "Windows audience" filter redundant.

  • Removes the windows-type badge from the Designations column and the Windows audience filter.
  • Adds an Age range filter over the 4 AgeRange categories.
  • Filter matches an org when either its age-range tags (org's own or affiliated people's) include the selected range or its windows audience semantically covers it — so orgs with a windows audience but no/conflicting tags still surface.
  • Surfaces the windows-type badge in the age-range column when the windows audience adds age info the tags don't already convey (no tags, or tags that omit a range the audience covers).

Notes

  • WindowsTypeFilterable is left intact — it's shared by many other models; only the org index stops using windows_type_name.
  • Index eager-loads the windows type's age-range categories to avoid an N+1 behind the new badge logic.

Test plan

  • spec/models/organization_spec.rb covers .age_range_names (org tag / affiliated-person tag / windows-audience fallback / exclusion) and #windows_audience_unreflected_by_age_tags?.

.where(categorizable_items: { category_id: category_ids })
.select(:id)

where(id: org_tagged).or(where(id: via_affiliations)).or(where(windows_type_id: windows_type_ids))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 From Claude: Three-legged OR is the heart of the filter: org-own tag, affiliated-person tag (mirrors the column's aggregation), or windows-audience semantic coverage. All three are plain wheres on organizations with no joins, so .or stays structurally compatible.

def windows_audience_unreflected_by_age_tags?
return false unless windows_type
tagged = all_primary_age_groups + all_additional_age_groups
return true if tagged.empty?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 From Claude: Empty tags → true is intentional: an org with a windows audience but no age tags is exactly the case we want to surface the badge for. Otherwise we only show it when the audience covers a range the tags omit.

:windows_type, :organization_status, :sectors, :addresses,
:organization_status, :sectors, :addresses,
{ windows_type: { categorizable_items: { category: :category_type } } },
{ categorizable_items: { category: :category_type } },

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 From Claude: Eager-loads the windows type's age-range categories so windows_audience_unreflected_by_age_tags? (which reads categorizable_items in Ruby) doesn't N+1 across the 25 rows per page.

The age-range category tags now carry audience info on the organizations
index, so the separate windows-type column and "Windows audience" filter
are redundant. Replace them with a single "Age range" filter over the
AgeRange categories.

Because some orgs have a windows audience but no age-range tags — or tags
that disagree with it — matching ORs the org's (and affiliated people's)
age-range tags with the windows audience's semantic age ranges, and the
windows-type badge is surfaced in the age-range column whenever it adds
age info the tags don't already convey.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@maebeale maebeale force-pushed the maebeale/age-range-filter-windows-type branch from 2b443be to 073b692 Compare June 29, 2026 12:27
@maebeale maebeale changed the title Replace org-index windows-type filter/column with age-range filter HOLD: Replace org-index windows-type filter/column with age-range filter Jul 4, 2026
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