Skip to content

Commit

Permalink
coerce types, handle empty strings
Browse files Browse the repository at this point in the history
  • Loading branch information
elewis2 committed Dec 24, 2023
1 parent e58438e commit 87c25d9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/moa/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const pubmed = require('../entrez/pubmed');
const _trials = require('../clinicaltrialsgov');


const ajv = new Ajv({ allErrors: true });
const ajv = new Ajv({ allErrors: true, coerceTypes: true });
const validateMoaRecord = ajv.compile(spec);


Expand Down Expand Up @@ -453,6 +453,9 @@ const fixStringNulls = (obj) => {
/**
* Any values of "None" replace with null
*/
if (obj === '') {
return null;
}
if (obj === 'None') {
return null;
}
Expand Down Expand Up @@ -544,6 +547,7 @@ const upload = async ({ conn, url = 'https://moalmanac.org/api/assertions' }) =>
try {
logger.info(`loading: ${rawRecord.assertion_id} / ${records.length}`);
const record = fixStringNulls(rawRecord);

Check failure on line 550 in src/moa/index.js

View workflow job for this annotation

GitHub Actions / node-12

Trailing spaces not allowed

Check failure on line 550 in src/moa/index.js

View workflow job for this annotation

GitHub Actions / node-16

Trailing spaces not allowed
checkSpec(validateMoaRecord, record);

const key = `${record.assertion_id}`;
Expand Down Expand Up @@ -582,6 +586,7 @@ const upload = async ({ conn, url = 'https://moalmanac.org/api/assertions' }) =>
}
}
}
//throw new Error('dont make a complete file');

Check failure on line 589 in src/moa/index.js

View workflow job for this annotation

GitHub Actions / node-12

Expected exception block, space or tab after '//' in comment

Check failure on line 589 in src/moa/index.js

View workflow job for this annotation

GitHub Actions / node-16

Expected exception block, space or tab after '//' in comment
logger.info(JSON.stringify(counts));
};

Expand Down

0 comments on commit 87c25d9

Please sign in to comment.