From 3c03ad631885a5cd3151c75de83e20b367e5d1cf Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 23 Oct 2019 11:37:40 -0400 Subject: [PATCH] LP1849523 Angular catalog split record batches The result page of the Angular catalog now fetches the record info in 2 batches. The first batch is relatively small (currently 5 records) and allows the results page to start rendering results earlier in the display process. The second batch of records, which includes all the rest of the results, then drops in as they arrive. Note the first batch of records will be the first 5 results from the search so the second batch of results can simply be appended and avoid page shuffling. Includes thinko fix for batched holds retrieval. Signed-off-by: Bill Erickson --- .../src/eg2/src/app/share/catalog/catalog.service.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts index 528de96fdf..670e10c4fd 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts @@ -1,6 +1,6 @@ import {Injectable, EventEmitter} from '@angular/core'; import {Observable} from 'rxjs'; -import {map, tap, finalize} from 'rxjs/operators'; +import {map, tap, finalize, merge} from 'rxjs/operators'; import {OrgService} from '@eg/core/org.service'; import {UnapiService} from '@eg/share/catalog/unapi.service'; import {IdlService, IdlObject} from '@eg/core/idl.service'; @@ -12,6 +12,11 @@ import {BasketService} from './basket.service'; import {CATALOG_CCVM_FILTERS} from './search-context'; import {ElasticService} from './elastic.service'; +// Start with this number of records in the first batch so results +// can start displaying sooner. A batch of 5 gets a decent chunk of +// data on the page while waiting for the other results to appear. +const INITIAL_REC_BATCH_SIZE = 5; + @Injectable() export class CatalogService { @@ -224,7 +229,18 @@ export class CatalogService { const isMeta = ctx.termSearch.isMetarecordSearch(); + // When fetching batches of search results, fetch the first + // few records first so results lists can start rendering + // before the full data set has arrived and been processed. + let ids1 = ctx.currentResultIds(); + let ids2 = []; + if (ids1.length > INITIAL_REC_BATCH_SIZE) { + ids1 = ctx.currentResultIds().slice(0, INITIAL_REC_BATCH_SIZE); + ids2 = ctx.currentResultIds().slice(INITIAL_REC_BATCH_SIZE); + } + let observable: Observable; + const bibFunc = isMeta ? 'getMetabibSummary' : 'getBibSummary'; const options: any = {pref_ou: ctx.prefOu}; -- 2.11.0