From 6e341d0ea3b4b2ef2afcdb662c50e344e5160d76 Mon Sep 17 00:00:00 2001 From: bchu1 <151689101+bchu1@users.noreply.github.com> Date: Tue, 19 Mar 2024 16:21:03 -0700 Subject: [PATCH] feat: Parallelize the Rails and NexGen join calls for fedSequencingReads ID query (#216) --- resolvers.ts | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/resolvers.ts b/resolvers.ts index d7b670e4..f21203ba 100644 --- a/resolvers.ts +++ b/resolvers.ts @@ -829,22 +829,8 @@ export const resolvers: Resolvers = { // NEXT GEN: const nextGenEnabled = await shouldReadFromNextGen(context); if (nextGenEnabled) { - console.log("bchu: " + queryingIdsOnly); if (queryingIdsOnly) { - console.log( - "bchu: " + convertSequencingReadsQuery(context.params.query), - ); - console.log( - "bchu: " + - JSON.stringify({ - where: { - collectionId: input.where?.collectionId, - taxon: input.where?.taxon, - consensusGenomes: input.where?.consensusGenomes, - }, - }), - ); - const nextGenResponse = await fetchFromNextGen({ + const nextGenPromise = fetchFromNextGen({ customQuery: convertSequencingReadsQuery(context.params.query), customVariables: { // Entities Service doesn't support sample metadata yet. @@ -858,9 +844,7 @@ export const resolvers: Resolvers = { args, context, }); - console.log("bchu: " + JSON.stringify(nextGenResponse)); - let sequencingReads = nextGenResponse.data.sequencingReads; - if (input.where?.sample != null && sequencingReads.length > 0) { + if (input.where?.sample != null) { const filteredSampleIds = new Set( ( await getFromRails({ @@ -879,13 +863,13 @@ export const resolvers: Resolvers = { }) ).all_samples_ids, ); - console.log("bchu: " + JSON.stringify(filteredSampleIds)); - sequencingReads = sequencingReads.filter(sequencingRead => - filteredSampleIds.has(sequencingRead.sample.railsSampleId), + return (await nextGenPromise).data.sequencingReads.filter( + sequencingRead => + filteredSampleIds.has(sequencingRead.sample.railsSampleId), ); + } else { + return (await nextGenPromise).data.sequencingReads; } - console.log("bchu: " + JSON.stringify(sequencingReads)); - return sequencingReads; } const nextGenResponse = await fetchFromNextGen({