Skip to content

Commit

Permalink
HARMONY-1876: Submit harmony requests for all 3 datasets.
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-durbin committed Jan 7, 2025
1 parent 7cfad7e commit 32068c9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
20 changes: 16 additions & 4 deletions services/harmony/app/frontends/free-text-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ interface GeneratedHarmonyRequestParameters {
}

interface CmrAndHarmonyResponse {
statusUrl: string;
statusUrls: string[];
collections: any;
}

Expand Down Expand Up @@ -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,
};

Expand Down
12 changes: 8 additions & 4 deletions services/harmony/app/views/free-text-query/index.mustache.html
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,11 @@ <h2 id="dataset-title-3" class="dataset-title"></h2>
}

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';
Expand Down Expand Up @@ -633,9 +637,9 @@ <h2 id="dataset-title-3" class="dataset-title"></h2>
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');

Expand Down

0 comments on commit 32068c9

Please sign in to comment.