From 32068c9417b6d455be337e976beab6cab4c2f560 Mon Sep 17 00:00:00 2001 From: Chris Durbin Date: Tue, 7 Jan 2025 14:48:37 -0500 Subject: [PATCH] HARMONY-1876: Submit harmony requests for all 3 datasets. --- .../harmony/app/frontends/free-text-query.ts | 20 +++++++++++++++---- .../views/free-text-query/index.mustache.html | 12 +++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/services/harmony/app/frontends/free-text-query.ts b/services/harmony/app/frontends/free-text-query.ts index 85d9bfe51..0e5a10ef9 100644 --- a/services/harmony/app/frontends/free-text-query.ts +++ b/services/harmony/app/frontends/free-text-query.ts @@ -70,7 +70,7 @@ interface GeneratedHarmonyRequestParameters { } interface CmrAndHarmonyResponse { - statusUrl: string; + statusUrls: string[]; collections: any; } @@ -349,10 +349,22 @@ export async function freeTextGetCmrResults( queryParams.format = outputFormat; } - const harmonyJob = await submitHarmonyRequest(collectionsInfo[0][0].collection_id, collectionsInfo[0][0].variable_id, queryParams, geoJson, req.accessToken); - logPerf(now, 'submit harmony request'); + const statusUrls = []; + i = 0; + for (const collectionId of collConceptIds) { + // const harmonyJob = await submitHarmonyRequest(collectionsInfo[i][0].collection_id, collectionsInfo[i][0].variable_id, queryParams, geoJson, req.accessToken); + try { + const harmonyJob = await submitHarmonyRequest(collectionId, collectionsInfo[i][0].variable_id, queryParams, geoJson, req.accessToken); + const statusUrl = harmonyJob.links[2].href; + statusUrls.push(statusUrl); + i = i + 1; + logPerf(now, 'submit harmony request'); + } catch (e) { + console.log(`Failed to submit harmony request: ${e}`); + } + } const cmrResults: CmrAndHarmonyResponse = { - statusUrl: harmonyJob.links[2].href, + statusUrls, collections: collectionsInfo, }; diff --git a/services/harmony/app/views/free-text-query/index.mustache.html b/services/harmony/app/views/free-text-query/index.mustache.html index 78f554dba..d67d42943 100644 --- a/services/harmony/app/views/free-text-query/index.mustache.html +++ b/services/harmony/app/views/free-text-query/index.mustache.html @@ -542,7 +542,11 @@

} status.innerHTML = 'Waiting for harmony output'; - pollJobStatus(data.statusUrl); + let i = 0; + for (const url of data.statusUrls) { + i = i + 1; + pollJobStatus(url, i); + } } catch (e) { console.log(e); spinner.style.display = 'none'; @@ -633,9 +637,9 @@

const heat = L.heatLayer(heatMapData, { radius: 10, max: maxVal - minVal, blur: 0, minOpacity: 1 }).addTo(map1); } - export function pollJobStatus(statusUrl) { - const statusElement = document.getElementById('job-status-1'); - const imageElement = document.getElementById('dynamic-image-1'); + export function pollJobStatus(statusUrl, datasetId) { + const statusElement = document.getElementById(`job-status-${datasetId}`); + const imageElement = document.getElementById(`dynamic-image-${datasetId}`); const spinner = document.getElementById('spinner'); const status = document.getElementById('status-message');