Skip to content
Snippets Groups Projects
Commit 9cad39ff authored by Kristof De Langhe's avatar Kristof De Langhe
Browse files

Merge remote-tracking branch 'origin/performance-improvements-fall-2019' into...

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
parents 90436f3b e2696132
Branches
Tags
No related merge requests found
dspace.dir=/dspace
db.url=jdbc:postgresql://dspacedb:5432/dspace
dspace.hostname=dspace
dspace.baseUrl=http://localhost:8080
dspace.baseUrl=http://localhost:8080/server
dspace.name=DSpace Started with Docker Compose
solr.server=http://dspacesolr:8983/solr
......@@ -161,7 +161,10 @@ export class RemoteDataBuildService {
const objectList = normalized[relationship].page || normalized[relationship];
if (typeof objectList !== '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 = [];
......@@ -175,7 +178,10 @@ export class RemoteDataBuildService {
result = rdArr[0];
}
} 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)
// in that case only 1 href will be stored in the normalized obj (so the isArray above fails),
......
......@@ -151,6 +151,8 @@ export class FindAllRequest extends GetRequest {
}
export class EndpointMapRequest extends GetRequest {
public responseMsToLive = Number.MAX_SAFE_INTEGER;
constructor(
uuid: string,
href: string,
......
......@@ -222,7 +222,7 @@ export class RequestService {
* @param {GetRequest} request The request to check
* @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 inObjCache = this.objectCache.hasBySelfLink(request.href);
const isCached = inReqCache || inObjCache;
......
......@@ -4,13 +4,14 @@ import {
map,
mergeMap,
startWith,
switchMap,
switchMap, take,
tap
} from 'rxjs/operators';
import { RequestEntry } from '../data/request.reducer';
import { RequestService } from '../data/request.service';
import { GlobalConfig } from '../../../config/global-config.interface';
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 { Inject, Injectable } from '@angular/core';
import { GLOBAL_CONFIG } from '../../../config';
......@@ -36,7 +37,11 @@ export class HALEndpointService {
private getEndpointMapAt(href): Observable<EndpointMap> {
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(
getResponseFromEntry(),
map((response: EndpointMapSuccessResponse) => response.endpointMap),
......@@ -44,7 +49,7 @@ export class HALEndpointService {
}
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>;
if (halNames.length === 1) {
return nextHref$;
return nextHref$.pipe(take(1));
} else {
return nextHref$.pipe(
switchMap((nextHref) => this.getEndpointAt(nextHref, ...halNames.slice(1)))
switchMap((nextHref) => this.getEndpointAt(nextHref, ...halNames.slice(1))),
take(1)
);
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment