feat: sync GridSmart agendas and use event-relative demo time

Support script and URL sources, automatic Sessionize polling, staff-linked service sessions, chronological agenda blocks, and inline Placeholders. Fix demo mode to use the active event date and document deployed behavior with regression coverage.
This commit is contained in:
Lago committed 2026-10-11 08:39:15 +02:00
1 parent 40f24cf5f7
commit c0fbf495dc
27 files changed
+1215 -60

No files matched your search

+47 -8
View File
@@ -2,16 +2,17 @@
The **sidecar** is a small Node HTTP service that syncs an event's agenda from
[Sessionize](https://sessionize.com) into Convivo. It is the only server-side
component that holds the **service-role key**, and it is driven entirely by the
APPE Admin **Interfaces** menu — it runs **on demand only** (no scheduling).
component that holds the **service-role key**. Sessionize runs on demand from
Admin and automatically for active configured events, initially at startup and
then every 15 minutes. Pretix retains its independent every-minute loop.
- Code: [`apps/sidecar/`](../../apps/sidecar/), HTTP service in
[`src/server.js`](../../apps/sidecar/src/server.js), pure Excel transform in
[`src/transform-excel.js`](../../apps/sidecar/src/transform-excel.js)
- Image: [`apps/sidecar/Dockerfile`](../../apps/sidecar/Dockerfile)
(`node:20-alpine`; runtime dependencies **`xlsx`** (parse the Sessionize Excel
export) and **`pdfkit`** (render the PDF report) — everything else is built-in
`http` + `fetch`)
export), **`cheerio`** (parse GridSmart HTML without executing scripts), and
**`pdfkit`** (render the PDF report in the repository's newer server baseline))
- Compose service: `convivo-sidecar` in the root
[`docker-compose.yml`](../../docker-compose.yml) (`:3002`)
- DB side: the `sync_sessionize_event` RPC + `sync_runs` audit table — see
@@ -19,15 +20,52 @@ APPE Admin **Interfaces** menu — it runs **on demand only** (no scheduling).
## What it does
There are **two import paths**, both on demand:
There are **two import paths**; the source/API path also runs automatically:
**A. API sync** (`POST /run`) — fetches the event's `sessionize_endpoint` and
imports, in order: (1) speakers as contacts (matched by **email**), (2) sessions
(upserted by `external_id`), (3) the agenda/schedule (slots find-or-created by
date/start/end + `session_speakers` links). The public `/view/` payload has no
date/start/end/type + `session_speakers` links). The public `/view/` payload has no
speaker emails, so this path imports sessions + agenda but **skips speakers**
(unless an authenticated `/api/` endpoint + key is configured).
### GridSmart Sources and Polling
The Admin event editor accepts either an HTTPS Sessionize `All` / `GridSmart`
URL or one `<script src="...">` embed. It extracts and stores the URL, never
executes the script, and reports invalid input without saving. The sidecar also
normalizes stored script tags for compatibility. Only the exact
`sessionize.com/api/v2/<id>/view/All` and `.../GridSmart` paths are accepted;
credentials, alternate hosts, ports and HTTP are rejected. Queries and fragments
are removed. Requests have a 30-second timeout and do not follow redirects.
JSON `All` feeds retain their existing transform. For embed responses, the source
reader loads GridSmart HTML using `under=True` and parses stable `data-sessionid`
values, titles, rooms, service/plenum classes and UTC timing attributes. The
loader's explicit event UTC offset converts those times to event-local date/time.
Duplicate rendered cards are deduplicated by ID; conflicting copies, malformed
timings, empty grids, unknown timezones and overnight sessions fail validation.
The grid does not supply email addresses. Existing speaker links, descriptions,
level/area and materials are retained rather than replaced with missing data.
New speaker contacts still require the email-bearing Excel import. Service
sessions receive all event staff. Concurrent service placeholders use separate
service slots instead of being typed as ordinary talks.
Polling selects only active events with a configured source, processes them
sequentially, skips overlapping imports and retries failed sources on the next
pass. Set `SESSIONIZE_SYNC_INTERVAL_MS` in the sidecar container environment to
override the default `900000`; positive values are clamped to at least `60000`,
and `0` disables automatic polling. `/status` reports `sessionizeIntervalMs` and
the last run, including `source_format`. The Admin description reflects the
default interval. Manual Sync remains available for inactive configured events.
Successful imports upsert stable Sessionize IDs; missing entries are not deleted.
Migration `20261011060534_gridsmart_service_identity` also adopts the four
supplemental `manual-service-*` IDs when exactly one service matches the event,
title, date and timing, preserving its session ID and existing links. See the
[deployment record](../releases/2026-10-11.md#gridsmart-automation).
> **Service sessions.** A session is flagged `is_service_session` when
> Sessionize marks it `isServiceSession` **or** `isPlenumSession` (a plenum is a
> full-hall item — breaks, lunch, closing, or a plenary — with no individual
@@ -137,7 +175,8 @@ flowchart LR
- **Supabase:** PostgREST at `supabase_kong_Convivo:8000` (Kong's internal port
on the shared network — see [supabase-core.md#ports](./supabase-core.md#ports)),
authenticated with the **service-role key**.
- **Sessionize:** the event's stored `sessionize_endpoint`, fetched **as-is**.
- **Sessionize:** the event's stored `sessionize_endpoint`, normalized and read
as JSON or a non-executed GridSmart embed.
The public `/view/` endpoint needs no key. If `SESSIONIZE_API_KEY` is set it
is sent as the `X-Sessionize-API-Key` header (harmless for `/view/`, required
for an `/api/` endpoint).
@@ -154,7 +193,7 @@ flowchart LR
| Method | Path | Body | Returns |
|---|---|---|---|
| `GET` | `/health` | — | `{ ok: true }` (compose healthcheck) |
| `GET` | `/status` | — | `{ ok, running, lastRun }` |
| `GET` | `/status` | — | `{ ok, running, lastRun, sessionizeIntervalMs, ... }` |
| `POST` | `/run` | `{ event_id }` | **blocking** — the API-sync result (summary + errors) |
| `POST` | `/import-excel` | `multipart/form-data` (`event_id` + `file` = the `.xlsx`) | **blocking** — the Excel-import result (summary + errors) |
| `POST` | `/export` | `{ event_id, format: 'csv' \| 'xlsx' \| 'pdf', tables? }` | **blocking** — `{ filename, mime, content_base64 }` (the event report) |