football-docs 0.17.2 → 0.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/docs.db +0 -0
- package/dist/reep.js +35 -8
- package/docs/reep/overview.md +3 -1
- package/package.json +1 -1
package/data/docs.db
CHANGED
|
Binary file
|
package/dist/reep.js
CHANGED
|
@@ -147,7 +147,20 @@ async function localLookup(register, q) {
|
|
|
147
147
|
});
|
|
148
148
|
if (!entity.length)
|
|
149
149
|
continue;
|
|
150
|
-
|
|
150
|
+
// A release can leave a provider ID on a merged Reep ID, not on its survivor,
|
|
151
|
+
// so the survivor's own bridges are incomplete. Add the bridges of every ID
|
|
152
|
+
// merged into it (through chains, bounded), marked with the merged ID.
|
|
153
|
+
const bridges = await register.query([
|
|
154
|
+
"WITH RECURSIVE merged(id, depth) AS (",
|
|
155
|
+
" SELECT from_id, 1 FROM redirects WHERE to_id = $id",
|
|
156
|
+
" UNION ALL",
|
|
157
|
+
" SELECT r.from_id, m.depth + 1 FROM redirects r JOIN merged m ON r.to_id = m.id WHERE m.depth < 5",
|
|
158
|
+
")",
|
|
159
|
+
"SELECT provider, namespace, external_id, CASE WHEN reep_id = $id THEN NULL ELSE reep_id END AS via",
|
|
160
|
+
"FROM bridges WHERE reep_id = $id OR reep_id IN (SELECT id FROM merged)",
|
|
161
|
+
"ORDER BY provider, namespace, external_id, via NULLS FIRST",
|
|
162
|
+
].join("\n"), { id: target.id });
|
|
163
|
+
const own = new Set();
|
|
151
164
|
found.push({
|
|
152
165
|
reep_id: target.id,
|
|
153
166
|
label: String(entity[0].label),
|
|
@@ -155,11 +168,21 @@ async function localLookup(register, q) {
|
|
|
155
168
|
requested_id: target.id === hit.reep_id ? undefined : hit.reep_id,
|
|
156
169
|
matched: hit.matched,
|
|
157
170
|
matched_namespace: hit.matched_namespace,
|
|
158
|
-
bridges: bridges
|
|
171
|
+
bridges: bridges
|
|
172
|
+
.map((b) => ({
|
|
159
173
|
provider: String(b.provider),
|
|
160
174
|
namespace: String(b.namespace ?? ""),
|
|
161
175
|
external_id: String(b.external_id),
|
|
162
|
-
|
|
176
|
+
via: b.via == null ? undefined : String(b.via),
|
|
177
|
+
}))
|
|
178
|
+
.filter((b) => {
|
|
179
|
+
// The survivor's own bridge wins over the same provider ID on a merged ID.
|
|
180
|
+
const key = `${b.provider}\u0000${b.namespace}\u0000${b.external_id}`;
|
|
181
|
+
if (own.has(key))
|
|
182
|
+
return false;
|
|
183
|
+
own.add(key);
|
|
184
|
+
return true;
|
|
185
|
+
}),
|
|
163
186
|
});
|
|
164
187
|
}
|
|
165
188
|
if (q.kind === "reep_id" && tombstones.length)
|
|
@@ -345,7 +368,8 @@ function sqlFor(q) {
|
|
|
345
368
|
"FROM bridges b",
|
|
346
369
|
"LEFT JOIN redirects r ON r.from_id = b.reep_id",
|
|
347
370
|
"JOIN entities e ON e.reep_id = coalesce(nullif(r.to_id, ''), b.reep_id)",
|
|
348
|
-
"
|
|
371
|
+
"-- The survivor's provider IDs, plus any still attached to an ID merged into it.",
|
|
372
|
+
"JOIN bridges o ON o.reep_id = e.reep_id OR o.reep_id IN (SELECT from_id FROM redirects WHERE to_id = e.reep_id)",
|
|
349
373
|
`WHERE b.provider = ${quote(q.provider)}${q.namespace ? ` AND b.namespace = ${quote(q.namespace)}` : ""}`,
|
|
350
374
|
` AND b.external_id = ${quote(q.id)}`,
|
|
351
375
|
"ORDER BY o.provider, o.namespace;",
|
|
@@ -357,9 +381,11 @@ function sqlFor(q) {
|
|
|
357
381
|
"-- (reason de_corroborated) or withheld, not merged.",
|
|
358
382
|
`SELECT from_id, to_id, reason FROM redirects WHERE from_id = ${quote(q.reepId)};`,
|
|
359
383
|
"",
|
|
360
|
-
"-- Then follow a merge redirect to the survivor, and list every provider ID
|
|
361
|
-
"
|
|
362
|
-
"
|
|
384
|
+
"-- Then follow a merge redirect to the survivor, and list every provider ID, including",
|
|
385
|
+
"-- any still attached to an ID merged into it (bridged_on names that ID).",
|
|
386
|
+
"SELECT e.reep_id, e.label, e.entity_type, b.provider, b.namespace, b.external_id, b.reep_id AS bridged_on",
|
|
387
|
+
"FROM entities e",
|
|
388
|
+
"JOIN bridges b ON b.reep_id = e.reep_id OR b.reep_id IN (SELECT from_id FROM redirects WHERE to_id = e.reep_id)",
|
|
363
389
|
`WHERE e.reep_id = coalesce((SELECT nullif(to_id, '') FROM redirects WHERE from_id = ${quote(q.reepId)}), ${quote(q.reepId)})`,
|
|
364
390
|
` AND NOT EXISTS (SELECT 1 FROM redirects WHERE from_id = ${quote(q.reepId)} AND coalesce(to_id, '') = '')`,
|
|
365
391
|
"ORDER BY b.provider, b.namespace;",
|
|
@@ -408,7 +434,8 @@ function formatFound(found) {
|
|
|
408
434
|
lines.push(" (none)");
|
|
409
435
|
for (const b of f.bridges) {
|
|
410
436
|
const role = b.role && b.role !== "canonical_bridge" ? ` (${b.role})` : "";
|
|
411
|
-
|
|
437
|
+
const via = b.via ? ` (via merged ${b.via})` : "";
|
|
438
|
+
lines.push(` ${b.provider}${b.namespace ? ` / ${b.namespace}` : ""}: ${b.external_id}${role}${via}`);
|
|
412
439
|
}
|
|
413
440
|
}
|
|
414
441
|
else if (f.bridge_count !== undefined) {
|
package/docs/reep/overview.md
CHANGED
|
@@ -58,7 +58,9 @@ that answers the question from the download.
|
|
|
58
58
|
What the answers say:
|
|
59
59
|
|
|
60
60
|
- A merged Reep ID is followed to its survivor, and the answer names both IDs.
|
|
61
|
-
This includes a provider ID whose bridge still names the merged ID.
|
|
61
|
+
This includes a provider ID whose bridge still names the merged ID. The
|
|
62
|
+
survivor's provider IDs include any still attached to an ID merged into it,
|
|
63
|
+
marked "(via merged <id>)".
|
|
62
64
|
- A withdrawn or withheld Reep ID (a tombstone in `redirects`, with an empty
|
|
63
65
|
`to_id`) is reported as withdrawn or withheld, with the reason. It is not
|
|
64
66
|
reported as unknown: it was published, and the ID is never reused.
|
package/package.json
CHANGED