Cannabis Freedom Index

Changelog ca0e9ad

Handle known unprofiled places in colonial dataset mappings

3 files of code, design or docs +16 −3 lines

Code, design and documents 3 files

datasets/datasets.yaml +7 −1
@@ -964,5 +964,11 @@
   profile:
     headline: "Once ruled by {colonizer_names}"
-  country: { column: country, by: id, aliases: { tp: tl, yu: rs, zr: cd } }
+  country:
+    column: country
+    by: id
+    aliases: { tp: tl, yu: rs, zr: cd }
+    # These source places have no standalone profile. Retain their CSV rows, without
+    # assigning their colonial history to the administering country's profile.
+    unprofiled: [ai, an, tf, cc, ck, cx, eh, fk, gp, gf, ms, mq, nc, nf, nu, pn, re, sh, pm, tc, tk, wf]
   fields:
     colonizers: { column: colonizers, type: text, about: "Former colonial rulers, as country file names: Charts page" }

src/content.config.ts +5 −1
@@ -311,5 +311,9 @@ const datasets = defineCollection({
       notes: z.record(z.string(), z.string()).default({}), // by country file name
       // which column names the country; left out for a worldwide dataset, whose rows are kept as they are
-      country: z.object({ column: z.string().min(1), by: z.enum(["id", "name"]), aliases: z.record(z.string(), z.string()).default({}) }).strict().optional(),
+      country: z.object({
+        column: z.string().min(1), by: z.enum(["id", "name"]),
+        aliases: z.record(z.string(), z.string()).default({}),
+        unprofiled: z.array(z.string().min(1)).default([]), // known source places without a standalone profile
+      }).strict().optional(),
       year: z.object({ column: z.string().min(1) }).strict().optional(), // a column with the year of each row
       fields: z.record(z.string(), column),

src/lib/datasets.js +4 −1
@@ -80,5 +80,8 @@ const loaded = (await getCollection("datasets")).flatMap(({ data: def }) => {
       places.add(key);
       const id = def.country.aliases[key] ?? (def.country.by === "id" ? key.toLowerCase() : byName.get(norm(key)));
-      if (!id || !ids.has(id)) { missed.push(key); continue; }
+      if (!id || !ids.has(id)) {
+        if (!def.country.unprofiled.includes(key)) missed.push(key);
+        continue;
+      }
       const figures = {};
       for (const [name, { column, decimals, type }] of Object.entries(def.fields)) {

    ↑↓ to move, ↵ to open.