Skip to content

Commit

Permalink
metadata rails call added
Browse files Browse the repository at this point in the history
  • Loading branch information
rainandbare committed Mar 25, 2024
1 parent 4dbcaea commit f047714
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
39 changes: 27 additions & 12 deletions resolver-functions/BulkDownloadsCGOverview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { get, postWithCSRF, shouldReadFromNextGen } from "../utils/httpUtils";
import {
get,
getFromRails,
postWithCSRF,
shouldReadFromNextGen,
} from "../utils/httpUtils";

export const BulkDownloadsCGOverviewResolver = async (
root,
Expand All @@ -9,6 +14,14 @@ export const BulkDownloadsCGOverviewResolver = async (
if (!args?.input) {
throw new Error("No input provided");
}
const {
downloadType,
workflow,
includeMetadata,
workflowRunIds,
workflowRunIdsStrings,
} = args?.input;

/* --------------------- Next Gen ------------------------- */
const nextGenEnabled = await shouldReadFromNextGen(context);
if (nextGenEnabled) {
Expand Down Expand Up @@ -84,19 +97,21 @@ export const BulkDownloadsCGOverviewResolver = async (
]),
],
};
// TODO: Add Optional Sample Metadata
// if (args?.input?.includeMetadata) {
// call rails sample metadata query
//}
// TODO: Suzette & Jerry - Add Optional Sample Metadata
if (args?.input?.includeMetadata) {
const body = {
sample_ids: workflowRunIdsStrings,
};
const sampleMetadataRes = await postWithCSRF({
url: `/bulk_downloads/consensus_genome_sample_metadata`,
body,
args,
context,
});
console.log("sampleMetadataRes", sampleMetadataRes);
}
return formattedForCSV;
}
const {
downloadType,
workflow,
includeMetadata,
workflowRunIds,
workflowRunIdsStrings,
} = args?.input;

//array of strings to array of numbers
const workflowRunIdsNumbers = workflowRunIdsStrings?.map(
Expand Down
8 changes: 6 additions & 2 deletions utils/httpUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ export const get = async ({
});
} else {
if (!url) {
console.error(`You must pass a url to call rails. If you meant to call NextGen, set the serviceType. url: ${url}, serviceType: ${serviceType}`);
throw new Error(`You must pass a url to call rails. If you meant to call NextGen, set the serviceType. url: ${url}, serviceType: ${serviceType}`);
console.error(
`You must pass a url to call rails. If you meant to call NextGen, set the serviceType. url: ${url}, serviceType: ${serviceType}`,
);
throw new Error(
`You must pass a url to call rails. If you meant to call NextGen, set the serviceType. url: ${url}, serviceType: ${serviceType}`,
);
}
return getFromRails({ url, args, context, fullResponse });
}
Expand Down

0 comments on commit f047714

Please sign in to comment.