Skip to content

Commit 2b64f0e

Browse files
fix(petro): Multiple rows with same non-specific subtypes in reference sheet are acceptable
1 parent 0906328 commit 2b64f0e

1 file changed

Lines changed: 22 additions & 8 deletions

File tree

packages/etl/src/petrography-json.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ export function buildReferenceLookup(rows) {
7575
return lookup;
7676
}
7777

78+
export function isSpecificSingleSubtype(subtype) {
79+
return subtype &&
80+
subtype !== "unverified" &&
81+
subtype !== "unspecified" &&
82+
!subtype.includes("|");
83+
}
84+
7885
/**
7986
* Build a lookup Map of provenance data from the reference CSV rows.
8087
* Key: subtype value. Value: { placeName, coordinates, radius, uri }.
@@ -88,6 +95,11 @@ export function buildProvenance(rows) {
8895
let duplicateSubtypes = new Set()
8996
for (const row of rows) {
9097
const subtype = row["subtype"]?.trim();
98+
99+
if (!isSpecificSingleSubtype(subtype)) {
100+
continue;
101+
}
102+
91103
const placeName = row["placeName"]?.trim();
92104
// Strip all whitespace including non-breaking spaces (U+00A0) to get "lat,lon"
93105
const coordinates = row["coordinates"]?.replace(/[^\d.,\-]/g, "").trim();
@@ -348,14 +360,16 @@ export async function buildRecords({
348360
}
349361

350362
// Provenance: look up by subtype only for single-value specific subtypes
351-
const isSpecificSingleSubtype =
352-
subtype &&
353-
subtype !== "unverified" &&
354-
subtype !== "unspecified" &&
355-
!subtype.includes("|");
356-
const provenance = isSpecificSingleSubtype
357-
? (provenanceLookup.get(subtype) ?? null)
358-
: null;
363+
// GN: why not simply having this condition in the construction of provenanceLookup?
364+
// const isSpecificSingleSubtype =
365+
// subtype &&
366+
// subtype !== "unverified" &&
367+
// subtype !== "unspecified" &&
368+
// !subtype.includes("|");
369+
// const provenance = isSpecificSingleSubtype
370+
// ? (provenanceLookup.get(subtype) ?? null)
371+
// : null;
372+
const provenance = provenanceLookup.get(subtype) ?? null
359373

360374
const { ana, warnings: anaWarnings } = resolveAna(refLookup, type, subtype);
361375
results.push({

0 commit comments

Comments
 (0)