HOLD: Replace org-index windows-type filter/column with age-range filter#1927
HOLD: Replace org-index windows-type filter/column with age-range filter#1927maebeale wants to merge 1 commit into
Conversation
| .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)) |
There was a problem hiding this comment.
🤖 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? |
There was a problem hiding this comment.
🤖 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 } }, |
There was a problem hiding this comment.
🤖 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>
2b443be to
073b692
Compare
🤖 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.
Notes
WindowsTypeFilterableis left intact — it's shared by many other models; only the org index stops usingwindows_type_name.Test plan
spec/models/organization_spec.rbcovers.age_range_names(org tag / affiliated-person tag / windows-audience fallback / exclusion) and#windows_audience_unreflected_by_age_tags?.