Skip to content

Commit

Permalink
🐛 Fix mock studies script (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
evans-g-crsj authored Mar 6, 2024
1 parent c3a653b commit 45ee5bf
Show file tree
Hide file tree
Showing 5 changed files with 783 additions and 735 deletions.
6 changes: 4 additions & 2 deletions admin/addFieldsToStudies.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,16 @@ const operations = ms.flatMap(doc => {
return undefined;
}
return [
{ update: { _index: 'study_centric', _id: oDoc._id } },
{ update: { _index: oDoc._index, _id: oDoc._id } },
{
doc: {
...doc,
...oDoc._source,
...doc,
},
},
];
});

assert(operations.every(o => o !== undefined));
const br = await client.bulk({ refresh: true, body: operations });
assert(br.statusCode === 200 || !br.body?.errors, br);
Expand All @@ -121,6 +122,7 @@ const uItems = br.body.items;
// Not a perfect check theoretically, but it should be largely sufficient.
// Besides, identity ( f(x)=x ) transform is considered as an update
const allUpdated = uItems.length === ms.length;
console.log(sCodes)
console.log(
allUpdated
? 'All items were updated'
Expand Down
10 changes: 4 additions & 6 deletions admin/checkConf.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ const kfs = kfConf.extendedMappingMutations.map(m => [m.field, m.graphqlField]);
const incs = includeConf.extendedMappingMutations.map(m => [m.field, m.graphqlField]);

console.info('mutation in Kf only');
console.table(
kfs.filter(kf => !incs.some(ins => kf[0] === ins[0] && kf[1] === ins[1])).map(x => ({ field: x[0], entity: x[1] })),
);
const diffKfOnly = kfs.filter(kf => !incs.some(ins => kf[0] === ins[0] && kf[1] === ins[1])).map(x => ({ field: x[0], entity: x[1] }))
diffKfOnly.length === 0 ? console.log('No diff') : console.table(diffKfOnly)

console.info('mutation in Include only');
console.table(
incs.filter(ins => !kfs.some(kf => kf[0] === ins[0] && kf[1] === ins[1])).map(x => ({ field: x[0], entity: x[1] })),
);
const diffIncOnly = incs.filter(ins => !kfs.some(kf => kf[0] === ins[0] && kf[1] === ins[1])).map(x => ({ field: x[0], entity: x[1] }))
diffIncOnly.length === 0 ? console.log('No diff') : console.table(diffIncOnly)
Loading

0 comments on commit 45ee5bf

Please sign in to comment.