Real-time clock toggle: per-event use_realtime_clock flag
- Migration 20260834000000: events.use_realtime_clock (boolean, default false) - Admin: Real-time clock toggle in the Events create/edit modal - Convivo: useEvent picks new Date() vs simulated DEFAULT_NOW from the flag; Home shows a 'Demo clock' badge only in simulated mode - Docs: app-structure, admin-app, schema, next-steps Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
1 parent
bd67debeef
commit
f9a8513620
11 files changed
+113
-23
No files matched your search
@@ -78,6 +78,7 @@ queries everything for the active event and handles "no active event" gracefully
|
||||
| `num_registrations` | `integer` | maintained aggregate |
|
||||
| `num_checked_in_registrations` | `integer` | maintained aggregate |
|
||||
| `sessionize_endpoint` | `text` | nullable — the Sessionize API URL for this event (see [sidecar.md](./sidecar.md)) |
|
||||
| `use_realtime_clock` | `boolean` | default `false` — when `true`, the attendee app drives slot status (Live/Next/Done) from the real system clock; when `false` it uses the simulated mid-event clock (see [../frontend/app-structure.md](../frontend/app-structure.md)) |
|
||||
| `last_synced_at` | `timestamptz` | nullable — when the Sessionize sync last ran |
|
||||
| `created_at` | `timestamptz` | |
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
|
||||
| **Sponsors** | List (paid only visible to attendees; admin sees all). Add/edit (type, name, email, phone, paid, amount, **contact search-and-pick**). |
|
||||
| **Schedule** | Slots (with a **type optionset** — `Session` / `Service Session`) + sessions (with speakers 1:N via a **multi-select search dropdown**, material upload with a **submitted / not submitted** state, `average_feedback`, `ai_generated_feedback` + an **Evaluate** stub button). |
|
||||
| **Activity** | Tables of check-ins, connections, and feedback (per active event). |
|
||||
| **Events** | Create event, toggle active/inactive (a switch; only one can be active at a time — activating one deactivates the rest), edit dates/location + the **Sessionize endpoint**. Each row has a **Sync** button that runs a (blocking) Sessionize sync and shows a result modal. |
|
||||
| **Events** | Create event, toggle active/inactive (a switch; only one can be active at a time — activating one deactivates the rest), edit dates/location + the **Sessionize endpoint** + the **Real-time clock** toggle (on = the attendee app uses the real system clock for Live/Next/Done; off = the simulated mid-event clock, the default). Each row has a **Sync** button that runs a (blocking) Sessionize sync and shows a result modal. |
|
||||
| **Interfaces** | Manages the Sessionize sync **sidecar**: status (online / running / last run), a **Run sync** control (event picker + blocking run + result modal), an **Import Excel** control (upload the Sessionize "Sessions and speakers (advanced)" `.xlsx` + a "How to get this file" tooltip), and a **Recent runs** table from `sync_runs`. See [../backend/sidecar.md](../backend/sidecar.md). |
|
||||
|
||||
## Auth guard
|
||||
|
||||
@@ -56,7 +56,8 @@ interface EventData {
|
||||
slots: { slot: Slot; sessions: Session[] }[]; // grouped, ordered by slot id
|
||||
sessionById: Map<string, Session>;
|
||||
slotById: Map<number, Slot>;
|
||||
now: Date; // the (simulated) event clock
|
||||
now: Date; // the event clock (simulated or real, see below)
|
||||
clockMode: 'simulated' | 'realtime'; // which clock `now` came from
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
reload: () => void; // re-fetch (e.g. after a material upload)
|
||||
@@ -71,8 +72,11 @@ interface EventData {
|
||||
|
||||
## The event clock (`lib/time.ts`)
|
||||
|
||||
The app uses a **simulated "now"** so the demo always looks mid-event — it does
|
||||
**not** use the real system date:
|
||||
The app drives slot status (Live / Up next / Done) from a **"now"** that is
|
||||
either the **real system clock** or a **simulated mid-event clock**, decided per
|
||||
event by the `events.use_realtime_clock` flag (see
|
||||
[admin-app.md](./admin-app.md) for the toggle). By default it's the simulated
|
||||
clock, so the demo always looks mid-event:
|
||||
|
||||
```ts
|
||||
export const EVENT_DATE = '2026-02-20';
|
||||
@@ -84,10 +88,23 @@ the event day**, so the demo shows a live session no matter what the actual
|
||||
calendar date is (open it on 25 Aug 2026 and it still looks like it's 10:20 on
|
||||
20 Feb).
|
||||
|
||||
`useEvent()` picks the clock from the flag and exposes both the resulting `now`
|
||||
and which mode it used:
|
||||
|
||||
```ts
|
||||
const clockMode: 'simulated' | 'realtime' = event?.use_realtime_clock ? 'realtime' : 'simulated';
|
||||
const now = clockMode === 'realtime' ? new Date() : DEFAULT_NOW;
|
||||
```
|
||||
|
||||
The Home header shows a **🎬 Demo clock** indicator only when the simulated
|
||||
clock is active — when the real clock is on, nothing is shown (a real clock is
|
||||
the expected state, so it needs no badge).
|
||||
|
||||
### How "Live" / "Up next" / "Done" is decided
|
||||
|
||||
`slotStatus(slot, now)` compares the slot's start/end against `now` (the
|
||||
simulated clock, **not** `new Date()`):
|
||||
`slotStatus(slot, now)` compares the slot's start/end against `now` (the clock
|
||||
chosen above — simulated by default, or `new Date()` when the event's
|
||||
`use_realtime_clock` is on):
|
||||
|
||||
```ts
|
||||
export function slotStatus(slot: Slot, now: Date): SlotStatus {
|
||||
@@ -97,7 +114,7 @@ export function slotStatus(slot: Slot, now: Date): SlotStatus {
|
||||
}
|
||||
```
|
||||
|
||||
`useEvent()` exposes `now: DEFAULT_NOW`, and the screens derive:
|
||||
`useEvent()` exposes `now` (the chosen clock), and the screens derive:
|
||||
- **current** (the **Now** card) = the first slot where `slotStatus === 'now'`
|
||||
- **next** (the **Next** card) = the first slot where `slotStatus === 'next'`
|
||||
|
||||
@@ -113,17 +130,18 @@ At the frozen `10:20`, the seed's slots resolve to:
|
||||
So the Home screen shows a live Now card, an upcoming Next card, and a done slot
|
||||
that can carry a pending-feedback nudge.
|
||||
|
||||
> **Why a simulated clock?** The event day (20 Feb 2026) is in the past relative
|
||||
> to "today", so a real clock would mark **every** slot `done` — there'd be no
|
||||
> Live or Next card, just a wall of "Done". The frozen clock is what keeps the
|
||||
> demo looking alive on any date.
|
||||
> **Why a simulated clock by default?** The event day (20 Feb 2026) is in the
|
||||
> past relative to "today", so a real clock would mark **every** slot `done` —
|
||||
> there'd be no Live or Next card, just a wall of "Done". The frozen clock is
|
||||
> what keeps the demo looking alive on any date.
|
||||
|
||||
> **Using the real clock.** This is a **frontend-only** concern — the database
|
||||
> stores real slot times; the clock only decides which slot is "live" for
|
||||
> display. To drive it off the real date, replace `DEFAULT_NOW` with
|
||||
> `new Date()`. For a demo you'll show on arbitrary dates, a good middle ground
|
||||
> is: use `new Date()` when the event day is still in the future/present, and
|
||||
> fall back to the simulated mid-event clock once the event day has passed.
|
||||
> display. Flip the event's **Real-time clock** toggle in the admin app
|
||||
> (Events → Edit) to switch an event to the real system clock. With it on,
|
||||
> `now` is `new Date()`, so a past event shows every slot as Done and no
|
||||
> Now/Next card; a live event tracks the actual time of day. Turn it back off
|
||||
> to return to the simulated mid-event clock.
|
||||
|
||||
Helpers:
|
||||
|
||||
|
||||
+25
-6
@@ -40,9 +40,13 @@ current phase.
|
||||
> no pick; attendees who attended an over session (and aren't its speaker) get a
|
||||
> pending-feedback pill on Home that clears once they rate it; and a session's
|
||||
> speaker can see the rating + AI summary for their own session only after it's
|
||||
> over).
|
||||
> Remaining work is cross-cutting (real event clock, deployment, testing, and the
|
||||
> ticket/Pretix sync that will consume the speaker links by email).
|
||||
> over), and
|
||||
> **Real-time clock toggle** (a per-event `events.use_realtime_clock` flag,
|
||||
> toggled in the admin Events view, switches the attendee app between the real
|
||||
> system clock and the simulated mid-event clock for Live/Next/Done status; the
|
||||
> Home header shows a 🎬 Demo clock badge only in simulated mode).
|
||||
> Remaining work is cross-cutting (deployment, testing, and the ticket/Pretix
|
||||
> sync that will consume the speaker links by email).
|
||||
|
||||
## Done
|
||||
|
||||
@@ -472,11 +476,26 @@ slot is live.
|
||||
adds `_assign_service_session_speakers`, re-creates `checkin_attendee` (service
|
||||
guard) and both sync RPCs (service-session typing + staff speakers).
|
||||
|
||||
## Real-time clock toggle — ✅ complete
|
||||
|
||||
A per-event flag lets the admin decide, in real time, whether the attendee app
|
||||
drives slot status (Live/Next/Done) from the **real system clock** or the
|
||||
**simulated mid-event clock** (the default, so the demo always looks live).
|
||||
|
||||
- **Schema:** `events.use_realtime_clock` (`boolean`, default `false`).
|
||||
- **Admin:** a **Real-time clock** toggle in the Events create/edit modal
|
||||
(on = real clock, off = simulated). Saved via `upsertEvent`.
|
||||
- **App:** `useEvent()` picks `now` from the flag — `new Date()` when on,
|
||||
`DEFAULT_NOW` when off — and exposes `clockMode` (`'realtime'` |
|
||||
`'simulated'`). The Home header shows a **🎬 Demo clock** badge only in
|
||||
simulated mode (nothing when the real clock is on). With the real clock on and
|
||||
the event in the past, every slot is
|
||||
`done` (no Now/Next card); with it off, the simulated clock restores the live
|
||||
slot.
|
||||
- **Migration:** [`20260834000000_event_realtime_clock.sql`](../../supabase/migrations/20260834000000_event_realtime_clock.sql).
|
||||
|
||||
## Cross-cutting / later
|
||||
|
||||
- **Real event clock** — replace the simulated `DEFAULT_NOW`
|
||||
([frontend/app-structure.md#the-event-clock](./frontend/app-structure.md#the-event-clock))
|
||||
with `new Date()` for the live event.
|
||||
- **Subdomains** — `convivo.appe.at`, `admin.appe.at`, `db.appe.at` don't exist
|
||||
yet; everything is on localhost. DNS + TLS + a reverse proxy in front of the
|
||||
Supabase core will be needed for a real deployment.
|
||||
|
||||
Reference in new issue
Block a user