Skip to content

Commit 8a15f79

Browse files
committed
Add local dashboard staging
Shortcake-Parent: 2026-08-14-add-dashboard-analytics
1 parent bf79520 commit 8a15f79

7 files changed

Lines changed: 892 additions & 12 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ You will find the services at the following ports:
2929
Everything you need to get started is already configured
3030
and will work out of the box.
3131

32-
If you need to work with our Stripe or Pretix integration, you will have to ask
33-
on Slack which secret key you need and why you need it.
32+
If you need to work with Stripe or the hosted Pretix instance, ask on Slack
33+
which secret key you need and why you need it. Local Pretix development does
34+
not require shared credentials; see
35+
[`backend/dashboard/README.md`](backend/dashboard/README.md#local-setup).
3436

3537
Once given, create a `.env` file at the project root with inside:
3638

backend/dashboard/README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Dashboard data sources
2+
3+
The dashboard always reads conference, proposal, decision, grant, and allocated
4+
budget data from the configured Django database.
5+
6+
Ticket totals, gross ticket revenue, completed refunds, product mix, and the
7+
eight-week sales chart are calculated from Pretix's read-only Items and Orders
8+
APIs.
9+
10+
## Local setup
11+
12+
The default Docker configuration points the backend at an isolated local Pretix
13+
API. Pretix is optional and lives behind the `pretix` Compose profile, so it
14+
does not add startup time to unrelated development work.
15+
16+
To start Pretix without adding staged data:
17+
18+
```sh
19+
docker compose --profile pretix up -d --wait pretix
20+
```
21+
22+
The control panel is at <http://localhost:8345/control/>. The local-only login is
23+
`admin@localhost` / `admin` after running the stage seeder below.
24+
25+
### Dashboard stages
26+
27+
Run the disposable stage seeder from the repository root:
28+
29+
```sh
30+
./scripts/seed-dashboard-stage cfp-open
31+
```
32+
33+
Available stages are:
34+
35+
- `cfp-open`
36+
- `review`
37+
- `ticket-sales`
38+
- `conference-week`
39+
- `post-event`
40+
41+
Each run replaces only the `dashboard-local` conference and the matching
42+
`python-italia-local/dashboard-local` Pretix event. It creates deterministic
43+
proposal, vote, grant, reimbursement, product, order, and ticket histories for
44+
the selected point in time. Open the result at
45+
<http://localhost:8000/dashboard/dashboard-local>. The seeded Pretix shop is at
46+
<http://localhost:8345/python-italia-local/dashboard-local/>.
47+
48+
The seeder refuses to run when Django is not in debug mode or when `PRETIX_API`
49+
does not resolve to `pretix`, `localhost`, or `127.0.0.1`. Local Pretix uses its
50+
own PostgreSQL database and Docker volumes. Stop it with:
51+
52+
```sh
53+
docker compose --profile pretix stop pretix pretix-db
54+
```
55+
56+
Set `LOCAL_PRETIX_API` and `LOCAL_PRETIX_API_TOKEN` only when deliberately
57+
testing a different development instance. The existing `PRETIX_API_TOKEN` in
58+
`.env` is not used by the Compose backend, which prevents a local stage run from
59+
accidentally authenticating to hosted Pretix.
60+
61+
## Production behavior
62+
63+
Production already provides `PRETIX_API` and `PRETIX_API_TOKEN`. The response is
64+
reduced to aggregate values in memory: order codes, attendee details, email
65+
addresses, and other personal data are never cached or sent to the browser.
66+
67+
Pretix aggregates are cached for 15 minutes. API failures render a safe
68+
unavailable state instead of failing the whole dashboard, and that unavailable
69+
state is cached briefly so a Pretix outage cannot create a request storm.
70+
71+
The production dashboard is available at
72+
<https://admin.pycon.it/dashboard> and requires a staff account. Comparisons are
73+
limited to two additional conferences to bound cold-cache Pretix and database
74+
work. Relevant settings are:
75+
76+
```text
77+
DASHBOARD_REQUIRE_STAFF=true
78+
DASHBOARD_MAX_COMPARISON_CONFERENCES=2
79+
DASHBOARD_PRETIX_CACHE_TIMEOUT=900
80+
DASHBOARD_PRETIX_ERROR_CACHE_TIMEOUT=60
81+
PRETIX_API_TIMEOUT=10
82+
PRETIX_API_HOST=
83+
```
84+
85+
Use a least-privilege Pretix token with read access only to the required
86+
organizer/events and the Items and Orders resources.
87+
88+
Before enabling a release, verify the dashboard build check, the focused
89+
dashboard/Pretix tests, and a staff login against the deployed `/dashboard` URL.
90+
Ticket analytics may intentionally show as unavailable while Pretix is
91+
unreachable; proposal and grant analytics should continue to render.

0 commit comments

Comments
 (0)