Call local chapters groups, everywhere

The organization kind is 'group', its side table is groups, pages
live at /groups/<id> and the Community page's section is #groups.
Migration 052 converts existing databases: the kind and the tables
whose CHECKs name chapters are rebuilt, the front page count and
request category follow, and the site's own /chapters/ and
#chapters links in records are rewritten. Request files now go in
Requests/Groups on the shared drive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-30 13:19:51 -05:00
parent 175a18976d
commit 38aff34c97
42 changed files with 473 additions and 254 deletions

View file

@ -3,7 +3,7 @@
GET /events list + the event scopes
GET /events/:id one event, full body, people
GET /organizations list, ?kind=region|chapter|…
GET /organizations list, ?kind=region|group|…
GET /organizations/:id one organization's page
GET /teams list, ?org=slug
GET /teams/:id one team's page
@ -11,13 +11,13 @@
GET /awards/:id one award and its recipients
Organizations are one table, so they're one endpoint. A region
and a chapter differ by a handful of fields, which arrive under
and a group differ by a handful of fields, which arrive under
`details` rather than as separate routes, that's what lets a
list component be written once and pointed at any kind.
The lists leave out unlisted records (is_listed = 0); the
detail routes don't, since reaching one by its link is the
point. A region's chapters and an organization's events, teams
point. A region's groups and an organization's events, teams
and awards are lists too. See 027_listed.sql.
Responses carry their fallbacks already resolved: an event's
@ -70,7 +70,7 @@ const content = new Hono();
// anything. stale-while-revalidate keeps the page instant while the
// refresh happens behind it.
const ORG_KINDS = ["national", "region", "chapter", "partner"];
const ORG_KINDS = ["national", "region", "group", "partner"];
/* ── Loaders ───────────────────────────────────────────────── */
@ -112,7 +112,7 @@ function shapeHost(row) {
kind: row.host_kind, // 'organization' | 'person'
id: row.host_id,
name: row.host_name,
// Which of /regions, /chapters, /partners the slug belongs to.
// Which of /regions, /groups, /partners the slug belongs to.
// Null for a person, whose route needs no disambiguating.
org_kind: row.host_org_kind,
};
@ -264,11 +264,11 @@ function attachRegionDetails(db, orgs) {
)
.all(...ids);
// A region's chapters, enough of each for a list entry.
// A region's groups, enough of each for a list entry.
const children = db
.prepare(
`SELECT c.region_id, o.id, o.name, o.location_label, o.logo
FROM chapters c
FROM groups c
JOIN organizations o ON o.id = c.id AND o.is_published = 1 AND o.is_listed = 1
WHERE c.region_id IN (${marks(ids.length)})
ORDER BY o.sort_order, o.name`,
@ -309,20 +309,20 @@ function attachRegionDetails(db, orgs) {
scope: byId[org.id]?.scope ?? null,
map_note: byId[org.id]?.map_note ?? null,
areas: areasBy.get(org.id) ?? [],
chapters: childrenBy.get(org.id) ?? [],
groups: childrenBy.get(org.id) ?? [],
};
}
}
function attachChapterDetails(db, orgs) {
const ids = orgs.filter((o) => o.kind === "chapter").map((o) => o.id);
function attachGroupDetails(db, orgs) {
const ids = orgs.filter((o) => o.kind === "group").map((o) => o.id);
if (ids.length === 0) return;
const rows = db
.prepare(
`SELECT c.id, c.region_id, c.meets, c.started,
r.name AS region_name, r.color AS region_color
FROM chapters c
FROM groups c
LEFT JOIN organizations r ON r.id = c.region_id
WHERE c.id IN (${marks(ids.length)})`,
)
@ -331,7 +331,7 @@ function attachChapterDetails(db, orgs) {
const byId = Object.fromEntries(rows.map((r) => [r.id, r]));
for (const org of orgs) {
if (org.kind !== "chapter") continue;
if (org.kind !== "group") continue;
const row = byId[org.id] ?? {};
org.details = {
region_id: row.region_id ?? null,
@ -539,7 +539,7 @@ content.get("/events/:id", (c) => {
/* ── Organizations ─────────────────────────────────────────────
GET /organizations every published, listed org
GET /organizations?kind=region one kind
GET /organizations?kind=region,chapter
GET /organizations?kind=region,group
Whatever the kind, the common card fields are in the same
places, so a list component reads `name`, `color`, `logo` and
@ -584,13 +584,13 @@ content.get("/organizations", (c) => {
);
attachRegionDetails(db, organizations);
attachChapterDetails(db, organizations);
attachGroupDetails(db, organizations);
attachLeadership(db, organizations);
return json(c, { organizations });
});
/* One organization's page: region, chapter, partner or NGU. */
/* One organization's page: region, group, partner or NGU. */
content.get("/organizations/:id", (c) => {
const db = c.get("db");
const id = c.req.param("id");
@ -607,7 +607,7 @@ content.get("/organizations/:id", (c) => {
const one = [organization];
attachRegionDetails(db, one);
attachChapterDetails(db, one);
attachGroupDetails(db, one);
attachLeadership(db, one);
attachTeams(db, one);
attachAwards(db, one);
@ -637,8 +637,8 @@ content.get("/organizations/:id", (c) => {
GET /teams/:id one team's page
An unpublished organization hides its teams too, in both
routes. Without that join a retired chapter's board stays
reachable by URL after the chapter itself has gone.
routes. Without that join a retired group's board stays
reachable by URL after the group itself has gone.
───────────────────────────────────────────────────────────── */
content.get("/teams", (c) => {

View file

@ -5,7 +5,7 @@
One flat list per kind, each row just enough to name a record
and build its URL: id and name, plus the organization's kind,
which decides whether its page is /regions, /chapters or
which decides whether its page is /regions, /groups or
/partners. The QR code page reads it to offer "any page on the
site" without five list requests carrying descriptions, links
and blocks it would throw away.

View file

@ -69,7 +69,7 @@ feedback.post("/", async (c) => {
const email = clean(body.email, LIMITS.email);
const message = clean(body.message, LIMITS.message);
const pagePath = clean(body.pagePath, LIMITS.pagePath);
// The picker holds nav hashes ('#chapters'); the column holds ids.
// The picker holds nav hashes ('#groups'); the column holds ids.
const sectionId = clean(body.sectionId, LIMITS.sectionId).replace(/^#/, "");
const feedbackType = TYPES.includes(body.feedbackType)
? body.feedbackType

View file

@ -6,7 +6,7 @@
v_timeline has already done the resolution: an entry with no title
of its own carries the referenced record's name, an entry with no
date carries the event's starts_on, and org_kind rides along
because /regions, /chapters and /partners are three routes and only
because /regions, /groups and /partners are three routes and only
the database knows which a slug is.
What's left here is shaping, and three things the view can't do:

View file

@ -56,7 +56,7 @@ const PAGE_ID = "home";
const STAT_QUERIES = {
regions: `SELECT COUNT(*) AS n FROM organizations WHERE kind = 'region' AND is_published = 1 AND is_listed = 1`,
chapters: `SELECT COUNT(*) AS n FROM organizations WHERE kind = 'chapter' AND is_published = 1 AND is_listed = 1`,
groups: `SELECT COUNT(*) AS n FROM organizations WHERE kind = 'group' AND is_published = 1 AND is_listed = 1`,
partners: `SELECT COUNT(*) AS n FROM organizations WHERE kind = 'partner' AND is_published = 1 AND is_listed = 1`,
events_held: `SELECT COUNT(*) AS n FROM v_events
WHERE is_published = 1 AND is_listed = 1 AND effective_status = 'past'`,

View file

@ -2,7 +2,7 @@
REQUEST ROUTE: POST /api/requests
The Request form (/request): a blog post, an event, or a new or
updated chapter, region, partner, team, award or person, with up
updated group, region, partner, team, award or person, with up
to MAX_FILES attachments. Stored as a feedback row of type
'content' (046_content_requests.sql), files in Google Drive.
@ -30,7 +30,7 @@ const requests = new Hono();
const CATEGORIES = {
blog: ["new"],
event: ["new", "update"],
chapter: ["new", "update"],
group: ["new", "update"],
region: ["update"],
partner: ["new", "update"],
team: ["new", "update"],
@ -64,12 +64,12 @@ export function cleanDetails(raw) {
}
const MIN_MESSAGE = 10;
// Where in the shared drive the files go (googleService.js): a
// folder per type under Requests, eg. Requests/Chapters.
// folder per type under Requests, eg. Requests/Groups.
export const DRIVE_FOLDER = "Requests";
export const TYPE_FOLDERS = {
blog: "Blog Posts",
event: "Events",
chapter: "Chapters",
group: "Groups",
region: "Regions",
partner: "Partners",
team: "Teams",