[Explore & Library | explore-redesign]: searchResearchResults.service.ts: [Bug fix] Fix parsing of hostedBy_collectedFrom (download from/source) - initialize, add journal and sort outside the loop.

This commit is contained in:
Konstantina Galouni 2023-02-18 03:44:30 +02:00
parent 332a32a4e4
commit a4c9c63311
1 changed files with 8 additions and 6 deletions

View File

@ -220,11 +220,11 @@ export class SearchResearchResultsService {
let instance; let instance;
let length = Array.isArray(resData['children']['instance']) ? resData['children']['instance'].length : 1; let length = Array.isArray(resData['children']['instance']) ? resData['children']['instance'].length : 1;
result.hostedBy_collectedFrom = new Array<HostedByCollectedFrom>();
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
instance = Array.isArray(resData['children']['instance']) ? resData['children']['instance'][i] : resData['children']['instance']; instance = Array.isArray(resData['children']['instance']) ? resData['children']['instance'][i] : resData['children']['instance'];
this.parsingFunctions.parseTypes(result.types, types, instance); this.parsingFunctions.parseTypes(result.types, types, instance);
if(instance?.hasOwnProperty("hostedby")) { if(instance?.hasOwnProperty("hostedby")) {
result.hostedBy_collectedFrom = new Array<HostedByCollectedFrom>();
if(instance.hasOwnProperty("webresource")) { if(instance.hasOwnProperty("webresource")) {
let url = Array.isArray(instance['webresource'])?instance['webresource'][0].url:instance['webresource'].url; let url = Array.isArray(instance['webresource'])?instance['webresource'][0].url:instance['webresource'].url;
if(url.includes('&amp;')) { if(url.includes('&amp;')) {
@ -233,14 +233,16 @@ export class SearchResearchResultsService {
if(instance.hasOwnProperty("hostedby")) { if(instance.hasOwnProperty("hostedby")) {
this.parsingFunctions.parseHostedBy_collectedFrom(result.hostedBy_collectedFrom, instance, url, result.title.accessMode); this.parsingFunctions.parseHostedBy_collectedFrom(result.hostedBy_collectedFrom, instance, url, result.title.accessMode);
} }
result.hostedBy_collectedFrom.sort(this.parsingFunctions.compareHostedByCollectedFrom);
} }
} }
let journal = resData['journal']?resData['journal'].content:null;
result.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(
result.hostedBy_collectedFrom, result.publisher,
journal, result.identifiers);
} }
let journal = resData['journal']?resData['journal'].content:null;
result.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(
result.hostedBy_collectedFrom, result.publisher,
journal, result.identifiers);
console.log(result.hostedBy_collectedFrom);
result.hostedBy_collectedFrom.sort(this.parsingFunctions.compareHostedByCollectedFrom);
// Measure // Measure
result.measure = this.parsingFunctions.parseMeasures(resData['measure']); result.measure = this.parsingFunctions.parseMeasures(resData['measure']);
/////////////////////////// Athena Code /////////////////////////// /////////////////////////// Athena Code ///////////////////////////