Commit 96e987b
feat(importer): replace mysqldump-based importer with JSON snapshot importer
Each run fetches the public laddr dataset from `codeforphilly.org`'s
`?format=json` endpoints (tags, people, projects, project-updates,
project-buzz) and writes a full-tree snapshot commit on the
`legacy-import` branch in the public data repo. Consecutive runs diff
cleanly to show what changed upstream.
Differences from the prior mysqldump implementation:
- Reads JSON from the live site, not a SQL dump file. No fixture SQL
or mysqldump parser needed.
- Memberships and tag-assignments arrive via `?include=Tags,Memberships`
on the projects list (and `?include=Tags` on people) — no separate
`/project-memberships` or `/tag-assignments` list endpoints exist.
- Files on `legacy-import` are keyed by laddr's auto-increment ID
(`<sheet>/<legacyId>.toml`, composite for memberships and
tag-assignments) so re-runs overwrite stable paths.
- Full-tree replace per run, not per-entity upserts. The wipe + write
pattern is bare-git, not gitsheets transact, because the path
templates we want for diff-ability differ from the runtime spec's
slug-based paths. The legacy-import branch is parallel history —
runtime data lives on `main`, which the operator merges into
separately.
- UUIDs are read-forward from the previous snapshot when a path
already exists, so idempotence holds without depending on `now`.
- Pseudonymous author identity on every commit
(Code for Philly API <api@users.noreply.codeforphilly.org>).
Translator robustness improvements drawn from the live data:
- Tag handles with the dot stripped by laddr's JSON renderer
(`topicparking`) are recovered from the Title field
(`topic.Parking`) when present.
- Tag slug components with underscores are coerced to hyphens.
- Bios over 10k chars (spam accounts) are truncated with a warning.
- Full names over 120 chars are truncated.
- ChatChannel is coerced through the v1 regex (lowercase, strip
leading `#`, replace non-allowed chars with `-`).
CLI surface:
npm run -w apps/api script:import-laddr -- \
--source-host=codeforphilly.org \
--data-repo=$CFP_DATA_REPO_PATH \
--branch=legacy-import \
[--dry-run] [--no-commit] [--limit=N] [--verbose] \
[--page-size=N] [--delay-ms=N]
Private-store import (emails, password hashes, newsletter prefs) is out
of scope — the JSON endpoints expose public fields only. That will be
covered by a separate plan (per laddr-import-via-json.md).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 5fdfd25 commit 96e987b
7 files changed
Lines changed: 2017 additions & 1427 deletions
File tree
- apps/api
- scripts
- fixtures
- import-laddr
- tests
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
3 | 4 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
12 | 8 | | |
13 | 9 | | |
14 | 10 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
22 | | - | |
23 | | - | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | | - | |
| 29 | + | |
27 | 30 | | |
28 | | - | |
| 31 | + | |
29 | 32 | | |
30 | | - | |
| 33 | + | |
31 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
| |||
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
50 | 61 | | |
51 | | - | |
52 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
53 | 67 | | |
54 | 68 | | |
55 | | - | |
56 | | - | |
57 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
58 | 78 | | |
| 79 | + | |
| 80 | + | |
59 | 81 | | |
60 | | - | |
| 82 | + | |
| 83 | + | |
61 | 84 | | |
62 | 85 | | |
63 | 86 | | |
64 | 87 | | |
65 | 88 | | |
66 | 89 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
| 90 | + | |
73 | 91 | | |
74 | | - | |
75 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
76 | 96 | | |
77 | | - | |
78 | | - | |
| 97 | + | |
| 98 | + | |
79 | 99 | | |
80 | | - | |
| 100 | + | |
81 | 101 | | |
82 | | - | |
| 102 | + | |
83 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
84 | 107 | | |
85 | 108 | | |
86 | | - | |
| 109 | + | |
87 | 110 | | |
88 | 111 | | |
89 | | - | |
| 112 | + | |
90 | 113 | | |
91 | 114 | | |
92 | | - | |
93 | | - | |
94 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
95 | 119 | | |
96 | | - | |
| 120 | + | |
97 | 121 | | |
98 | 122 | | |
99 | 123 | | |
100 | 124 | | |
101 | 125 | | |
102 | 126 | | |
103 | 127 | | |
104 | | - | |
| 128 | + | |
105 | 129 | | |
106 | | - | |
107 | | - | |
108 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
109 | 136 | | |
110 | 137 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | 138 | | |
124 | 139 | | |
125 | 140 | | |
| |||
0 commit comments