Merge remote-tracking branch 'origin/performance-improvements-fall-2019' into w2p-65717_Bundles-in-edit-item

Conflicts:
	src/app/core/shared/hal-endpoint.service.ts
This commit is contained in:
Kristof De Langhe
2019-10-29 10:08:28 +01:00
5 changed files with 24 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
dspace.dir=/dspace dspace.dir=/dspace
db.url=jdbc:postgresql://dspacedb:5432/dspace db.url=jdbc:postgresql://dspacedb:5432/dspace
dspace.hostname=dspace dspace.hostname=dspace
dspace.baseUrl=http://localhost:8080 dspace.baseUrl=http://localhost:8080/server
dspace.name=DSpace Started with Docker Compose dspace.name=DSpace Started with Docker Compose
solr.server=http://dspacesolr:8983/solr solr.server=http://dspacesolr:8983/solr

View File

@@ -161,7 +161,10 @@ export class RemoteDataBuildService {
const objectList = normalized[relationship].page || normalized[relationship]; const objectList = normalized[relationship].page || normalized[relationship];
if (typeof objectList !== 'string') { if (typeof objectList !== 'string') {
objectList.forEach((href: string) => { objectList.forEach((href: string) => {
this.requestService.configure(new GetRequest(this.requestService.generateRequestId(), href)) const request = new GetRequest(this.requestService.generateRequestId(), href);
if (!this.requestService.isCachedOrPending(request)) {
this.requestService.configure(request)
}
}); });
const rdArr = []; const rdArr = [];
@@ -175,7 +178,10 @@ export class RemoteDataBuildService {
result = rdArr[0]; result = rdArr[0];
} }
} else { } else {
this.requestService.configure(new GetRequest(this.requestService.generateRequestId(), objectList)); const request = new GetRequest(this.requestService.generateRequestId(), objectList);
if (!this.requestService.isCachedOrPending(request)) {
this.requestService.configure(request)
}
// The rest API can return a single URL to represent a list of resources (e.g. /items/:id/bitstreams) // The rest API can return a single URL to represent a list of resources (e.g. /items/:id/bitstreams)
// in that case only 1 href will be stored in the normalized obj (so the isArray above fails), // in that case only 1 href will be stored in the normalized obj (so the isArray above fails),

View File

@@ -151,6 +151,8 @@ export class FindAllRequest extends GetRequest {
} }
export class EndpointMapRequest extends GetRequest { export class EndpointMapRequest extends GetRequest {
public responseMsToLive = Number.MAX_SAFE_INTEGER;
constructor( constructor(
uuid: string, uuid: string,
href: string, href: string,

View File

@@ -222,7 +222,7 @@ export class RequestService {
* @param {GetRequest} request The request to check * @param {GetRequest} request The request to check
* @returns {boolean} True if the request is cached or still pending * @returns {boolean} True if the request is cached or still pending
*/ */
private isCachedOrPending(request: GetRequest): boolean { public isCachedOrPending(request: GetRequest): boolean {
const inReqCache = this.hasByHref(request.href); const inReqCache = this.hasByHref(request.href);
const inObjCache = this.objectCache.hasBySelfLink(request.href); const inObjCache = this.objectCache.hasBySelfLink(request.href);
const isCached = inReqCache || inObjCache; const isCached = inReqCache || inObjCache;

View File

@@ -4,13 +4,14 @@ import {
map, map,
mergeMap, mergeMap,
startWith, startWith,
switchMap, switchMap, take,
tap tap
} from 'rxjs/operators'; } from 'rxjs/operators';
import { RequestEntry } from '../data/request.reducer';
import { RequestService } from '../data/request.service'; import { RequestService } from '../data/request.service';
import { GlobalConfig } from '../../../config/global-config.interface'; import { GlobalConfig } from '../../../config/global-config.interface';
import { EndpointMapRequest } from '../data/request.models'; import { EndpointMapRequest } from '../data/request.models';
import { hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util'; import { hasNoValue, hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util';
import { RESTURLCombiner } from '../url-combiner/rest-url-combiner'; import { RESTURLCombiner } from '../url-combiner/rest-url-combiner';
import { Inject, Injectable } from '@angular/core'; import { Inject, Injectable } from '@angular/core';
import { GLOBAL_CONFIG } from '../../../config'; import { GLOBAL_CONFIG } from '../../../config';
@@ -36,7 +37,11 @@ export class HALEndpointService {
private getEndpointMapAt(href): Observable<EndpointMap> { private getEndpointMapAt(href): Observable<EndpointMap> {
const request = new EndpointMapRequest(this.requestService.generateRequestId(), href); const request = new EndpointMapRequest(this.requestService.generateRequestId(), href);
this.requestService.configure(request); if (!this.requestService.isCachedOrPending(request)) {
// don't bother configuring the request if it's already cached or pending.
this.requestService.configure(request);
}
return this.requestService.getByHref(request.href).pipe( return this.requestService.getByHref(request.href).pipe(
getResponseFromEntry(), getResponseFromEntry(),
map((response: EndpointMapSuccessResponse) => response.endpointMap), map((response: EndpointMapSuccessResponse) => response.endpointMap),
@@ -44,7 +49,7 @@ export class HALEndpointService {
} }
public getEndpoint(linkPath: string, startHref?: string): Observable<string> { public getEndpoint(linkPath: string, startHref?: string): Observable<string> {
return this.getEndpointAt(startHref || this.getRootHref(), ...linkPath.split('/')); return this.getEndpointAt(startHref || this.getRootHref(), ...linkPath.split('/')).pipe(take(1));
} }
/** /**
@@ -71,10 +76,11 @@ export class HALEndpointService {
) as Observable<string>; ) as Observable<string>;
if (halNames.length === 1) { if (halNames.length === 1) {
return nextHref$; return nextHref$.pipe(take(1));
} else { } else {
return nextHref$.pipe( return nextHref$.pipe(
switchMap((nextHref) => this.getEndpointAt(nextHref, ...halNames.slice(1))) switchMap((nextHref) => this.getEndpointAt(nextHref, ...halNames.slice(1))),
take(1)
); );
} }
} }