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:
parent
175a18976d
commit
38aff34c97
42 changed files with 473 additions and 254 deletions
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue