Skip to content

chore(regions): remove region-level event defaults feature - #538

Merged
Ardnived merged 3 commits into
mainfrom
chore/remove-region-event-defaults
Jul 5, 2026
Merged

Ardnived merged 3 commits into
mainfrom
chore/remove-region-event-defaults

Conversation

@Ardnived

@Ardnived Ardnived commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Removes the region-level event defaults feature (eventDefaults group on Regions + its ancestor-inheritance hook), which nothing consumed.
  • The eventDefaultsFallback afterRead hook ran an extra regions query on every region read, and forwarded the client req without a select — 400-ing client reads that populated a region (e.g. GET /api/events?select[region]=true&depth=1, or the geojson feed).
  • Pure removal — no replacement. If region-scoped event defaults are wanted later, they should be built as a visible client-side prefill on event create, not a hidden read-time inheritance.

Changes

  • src/collections/Regions/Regions.ts — drop the eventDefaults field group + the eventDefaultsFallback afterRead registration (Events tab keeps its events join).
  • src/collections/Regions/hooks/eventDefaultsFallback.ts — deleted.
  • src/lib/atlas/regionWebPaths.ts — remove the now-dead RESOLVING_FLAG re-entrancy guard. It existed only to stop eventDefaultsFallback's selectless nested read from re-entering the webpath resolver; with that hook gone, the resolver's narrow select (slug + breadcrumbs) plus the per-request memo are sufficient. (This resolver arrived on main via feat(regions,events): server-computed webPath/webUrl + webPath in geojson feed #537 after this branch was cut — see Notes.)
  • seeds/atlas/import.ts — remove buildEventDefaults + its wiring; upsertRegion loses its now-unused languageCode param (and the legacy defaultLanguageCode it fed). timeZone is untouched — it still seeds each event's schedule timezone.
  • src/lib/timezones/index.ts — remove the orphaned getTimezoneOptions wrapper; SUPPORTED_TIMEZONES stays (the schedule field's timezone: true companions use it). Its unit test is repointed to SUPPORTED_TIMEZONES.
  • src/payload-types.ts — regenerated (drops the eventDefaults language/timezone unions; keeps feat(regions,events): server-computed webPath/webUrl + webPath in geojson feed #537's webPath/webUrl).
  • Tests/docs — remove the eventDefaults inheritance block from atlas-collections.int.spec.ts; refresh stale comments in languageOptions.ts and seeds/atlas/MIGRATION_PLAN.md.

Migration

  • New migration: src/migrations/20260705_134239_drop_region_event_defaults.ts
  • Impact: drops regions.event_defaults_language (+ enum) and the regions_event_defaults_time_zone table (+ FK/indexes/enum). The stored eventDefaults values are dropped (intended — the feature is being removed).
  • Reversible: yes — down() recreates the column, table, enums, FK, and indexes.

Test Results

  • Integration: regions + events-geojson + atlas-collections + event-verification — 44 passed (of 44); the webPath specs (from feat(regions,events): server-computed webPath/webUrl + webPath in geojson feed #537) confirm the resolver still behaves correctly without RESOLVING_FLAG.
  • Unit: 643 passed (of 643) — includes the repointed SUPPORTED_TIMEZONES test.
  • Lint: ✓ no errors · Typecheck: ✓ clean
  • E2E: N/A — no UI-behavior changes beyond removing an admin field.
  • Build: runs on the Railway preview deploy (which also applies the migration in-process on boot).

Manual verification

  1. In the admin, open a Region → Events tab: the "Event Defaults" collapsible (language + timeZone) is gone; the events join list still shows.
  2. Read a child region as an API client at depth ≥ 1 (or populate event.region): returns 200 — no more selectless internal regions query.
  3. webPath/webUrl still resolve on the geojson feed and region reads (unchanged by this PR).

Notes for reviewer

🤖 Generated with Claude Code

@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-538 July 5, 2026 13:46 Destroyed
Ardnived and others added 2 commits July 5, 2026 14:53
The `eventDefaults` group (language + timeZone) on Regions and its
`eventDefaultsFallback` afterRead inheritance hook were unconsumed —
nothing in this app or the Atlas client read the inherited values, yet
the per-read ancestor query fired on every region read (and, on the
feat/regions-events-webpath branch, forwarded the client `req` without a
`select`, 400-ing client reads that populated a region).

Remove the field group + admin UI, the afterRead hook, the seed
importer's `buildEventDefaults` wiring (+ orphaned legacy
`defaultLanguageCode`), the now-unused `getTimezoneOptions` helper, and
the associated tests. `SUPPORTED_TIMEZONES` stays (the schedule field's
`timezone: true` companions use it); its unit test is repointed there.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Drops the schema objects the removed Regions `eventDefaults` group
created: the `regions.event_defaults_language` column + its enum, and the
`regions_event_defaults_time_zone` table (+ FK/indexes) + its enum.
Reversible `down()` recreates them. Pairs with the field/hook removal in
the preceding commit.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@railway-app

railway-app Bot commented Jul 5, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-538 environment in sahajcloud

Service Status Web Updated (UTC)
SahajCloud ✅ Success (View Logs) Web Jul 5, 2026 at 2:01 pm

…olver

The `RESOLVING_FLAG` re-entrancy guard existed solely to stop the removed
`eventDefaultsFallback` afterRead hook — whose selectless nested `regions`
read returned full docs and re-triggered the webPath field hooks — from
making the resolver re-scan the tree per ancestor. With that hook gone,
the resolver is protected by its own narrow `select` (slug + breadcrumbs
only, so webPath/webUrl field hooks never run on its results) plus the
identity-keyed per-request memo. Remove the flag, the context clone, and
the short-circuit; #537's webPath integration tests still pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@Ardnived
Ardnived force-pushed the chore/remove-region-event-defaults branch from 3f9ceaa to 87899ee Compare July 5, 2026 13:59
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-538 July 5, 2026 13:59 Destroyed
@Ardnived
Ardnived merged commit 5ee753f into main Jul 5, 2026
2 checks passed
@Ardnived
Ardnived deleted the chore/remove-region-event-defaults branch July 5, 2026 15:29

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-538 — 87899ee8 Deployed Jul 5, 2026 by railway-app[bot]
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