stat2025 commited on
Commit
c34c7fd
·
verified ·
1 Parent(s): 1b2fc94

Preserve evidence across workbook updates

Browse files
Files changed (1) hide show
  1. app.js +9 -4
app.js CHANGED
@@ -182,18 +182,23 @@ function documentationRecord(row) {
182
  }
183
 
184
  function hydrateRecordKeys(records) {
 
185
  return records.map((record) => {
186
- if (record.sampleKey) return record;
187
  const match = payload?.rows.find((row) => {
188
  if (record.commercialRecord && row.commercialRecord === record.commercialRecord) {
189
- return !record.researcher || row.researcher === record.researcher;
190
  }
191
  return (
192
  normalize(row.establishmentName) === normalize(record.establishmentName) &&
193
- (!record.researcher || row.researcher === record.researcher)
194
  );
195
  });
196
- return { ...record, sampleKey: match?.sampleKey || "" };
 
 
 
 
197
  });
198
  }
199
 
 
182
  }
183
 
184
  function hydrateRecordKeys(records) {
185
+ const currentKeys = new Set(payload?.rows.map((row) => row.sampleKey) || []);
186
  return records.map((record) => {
187
+ if (record.sampleKey && currentKeys.has(record.sampleKey)) return record;
188
  const match = payload?.rows.find((row) => {
189
  if (record.commercialRecord && row.commercialRecord === record.commercialRecord) {
190
+ return true;
191
  }
192
  return (
193
  normalize(row.establishmentName) === normalize(record.establishmentName) &&
194
+ (!record.contractNumber || row.contractNumber === record.contractNumber)
195
  );
196
  });
197
+ return {
198
+ ...record,
199
+ sampleKey: match?.sampleKey || record.sampleKey || "",
200
+ researcher: match?.researcher || record.researcher,
201
+ };
202
  });
203
  }
204