Skip to content

Commit

Permalink
fix: check if patent is associated to compounds before inserting DBref
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoSilvestr committed Feb 15, 2024
1 parent e993d6c commit 7a0b29c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,13 @@ exports[`Aggregation ActivesOrNaturals 1`] = `
"nbActivities": 20,
"nbMassSpectra": 0,
"nbMolecules": 2,
"nbPatents": 1,
"nbPatents": 0,
"nbPubmeds": 0,
"nbTaxonomies": 1,
"noStereoOCL": {
"idCode": "ekTpA@@@LAEMGLn\\dTTRbRfLbteRrRTfbqbtRthdRjZFFfNnAQjjjjjjjfjjjjjijjh@@",
},
"patents": [
{
"$id": "EP-2078065-A2",
"$ref": "patents",
},
],
"patents": [],
"taxonomies": [
{
"class": "Magnoliopsida",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ export default async function getCompoundsInfo(
for (let patent of compoundsPatents) {
let patentCursor = await patentsCollection.find({ _id: patent });
let patentInfo = await patentCursor.next();
if (patentInfo) {
if (
patentInfo &&
patentInfo.data.title &&
patentInfo.data.nbCompounds > 0
) {
dbRefsPatents.push({ $ref: 'patents', $id: patentInfo._id });
}
}
Expand Down

0 comments on commit 7a0b29c

Please sign in to comment.