gramene-search 2.15.5 → 2.15.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +20 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -313,7 +313,7 @@ const $9d9aeaf9299e61a1$var$grameneTaxonomy = (0, $gXNCa$reduxbundler.createAsyn
|
|
|
313
313
|
persist: true,
|
|
314
314
|
staleAfter: 86400000,
|
|
315
315
|
getPromise: ({ store: store })=>{
|
|
316
|
-
return fetch(`${store.selectGrameneAPI()}/taxonomy?subset=gramene&rows=-1`).then((res)
|
|
316
|
+
return fetch(`${store.selectGrameneAPI()}/taxonomy?subset=gramene&rows=-1`).then((res)=>$9d9aeaf9299e61a1$var$okJson(res, 'taxonomy')).then((rows)=>$9d9aeaf9299e61a1$var$nonEmptyList(rows, 'taxonomy')).then((taxNodes)=>{
|
|
317
317
|
let taxonomy = (0, ($parcel$interopDefault($gXNCa$lodash))).keyBy(taxNodes, '_id');
|
|
318
318
|
taxNodes.forEach((t)=>{
|
|
319
319
|
t._id = +t._id; // ensure taxonomy id is a number
|
|
@@ -333,13 +333,28 @@ $9d9aeaf9299e61a1$var$grameneTaxonomy.reactGrameneTaxonomy = (0, $gXNCa$reduxbun
|
|
|
333
333
|
actionCreator: 'doFetchGrameneTaxonomy'
|
|
334
334
|
};
|
|
335
335
|
});
|
|
336
|
+
// A proxy hiccup can answer with a non-2xx status, or with 200 and an empty
|
|
337
|
+
// list, and `res.json()` happily parses both. createAsyncResourceBundle would
|
|
338
|
+
// then record a *success* with empty data and stamp lastSuccess, so with
|
|
339
|
+
// staleAfter of 24h the client keeps believing it has genomes/taxonomy for a
|
|
340
|
+
// whole day. Downstream that surfaces as "No genome found for {}" and a hard
|
|
341
|
+
// "Bin count mismatch!" from gramene-bins-client. Throwing instead lets the
|
|
342
|
+
// bundle record an error and retry.
|
|
343
|
+
function $9d9aeaf9299e61a1$var$okJson(res, what) {
|
|
344
|
+
if (!res.ok) throw new Error(`${what} failed (${res.status})`);
|
|
345
|
+
return res.json();
|
|
346
|
+
}
|
|
347
|
+
function $9d9aeaf9299e61a1$var$nonEmptyList(rows, what) {
|
|
348
|
+
if (!Array.isArray(rows) || rows.length === 0) throw new Error(`${what} returned no rows`);
|
|
349
|
+
return rows;
|
|
350
|
+
}
|
|
336
351
|
const $9d9aeaf9299e61a1$var$grameneMaps = (0, $gXNCa$reduxbundler.createAsyncResourceBundle)({
|
|
337
352
|
name: 'grameneMaps',
|
|
338
353
|
actionBaseType: 'GRAMENE_MAPS',
|
|
339
354
|
persist: true,
|
|
340
355
|
staleAfter: 86400000,
|
|
341
356
|
getPromise: ({ store: store })=>{
|
|
342
|
-
return fetch(`${store.selectGrameneAPI()}/maps?rows=-1`).then((res)
|
|
357
|
+
return fetch(`${store.selectGrameneAPI()}/maps?rows=-1`).then((res)=>$9d9aeaf9299e61a1$var$okJson(res, 'maps')).then((rows)=>$9d9aeaf9299e61a1$var$nonEmptyList(rows, 'maps')).then((maps)=>{
|
|
343
358
|
maps.forEach((m)=>{
|
|
344
359
|
m.regionLength = {};
|
|
345
360
|
m.regions.names.forEach((rname, idx)=>{
|
|
@@ -640,7 +655,9 @@ const $9d9aeaf9299e61a1$var$grameneTaxDist = {
|
|
|
640
655
|
// yet, or a non-faceted search is transiently in state). Bail to null
|
|
641
656
|
// until it's there rather than crashing on `a.length`.
|
|
642
657
|
const binFacet = grameneSearch && grameneSearch.facet_counts && grameneSearch.facet_counts.facet_fields && grameneSearch.facet_counts.facet_fields.fixed_1000__bin;
|
|
643
|
-
|
|
658
|
+
// Object.keys guards matter here: an empty {} is truthy, and building the
|
|
659
|
+
// bin mapper from one throws "Bin count mismatch!" and takes the page down.
|
|
660
|
+
if (binFacet && grameneTaxonomy && Object.keys(grameneTaxonomy).length && grameneMaps && Object.keys(grameneMaps).length) {
|
|
644
661
|
(0, ($parcel$interopDefault($gXNCa$lodash))).forIn(grameneMaps, (map, tid)=>{
|
|
645
662
|
if (grameneTaxonomy[tid]) grameneTaxonomy[tid].name = map.display_name;
|
|
646
663
|
});
|