From 57cd4c3f0c5f27810d48bd56f31e00083a59d5af Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Wed, 17 Jan 2024 20:06:19 -0800 Subject: [PATCH] removing unnecessary lighthouse call during sync. fixes #383 --- .../medical-sources-connected.component.ts | 1 + .../app/pages/explore/explore.component.ts | 24 +++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.ts b/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.ts index 90835822..e7dfc16e 100644 --- a/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.ts +++ b/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.ts @@ -48,6 +48,7 @@ export class MedicalSourcesConnectedComponent implements OnInit { //handle connected sources sources const connectedSources = results as Source[] forkJoin(connectedSources.map((source) => { + //TODO: remove this, and similar code in explore.component.ts if(source.platform_type == 'fasten' || source.platform_type == 'manual') { return this.lighthouseApi.getLighthouseCatalogBrand(source.platform_type) } else { diff --git a/frontend/src/app/pages/explore/explore.component.ts b/frontend/src/app/pages/explore/explore.component.ts index 370207be..5255648b 100644 --- a/frontend/src/app/pages/explore/explore.component.ts +++ b/frontend/src/app/pages/explore/explore.component.ts @@ -2,16 +2,13 @@ import { Component, OnInit } from '@angular/core'; import {FastenApiService} from '../../services/fasten-api.service'; import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; import {Source} from '../../models/fasten/source'; -import {forkJoin} from 'rxjs'; +import {forkJoin, of} from 'rxjs'; import {LighthouseService} from '../../services/lighthouse.service'; import {Router} from '@angular/router'; import {LighthouseBrandListDisplayItem} from '../../models/lighthouse/lighthouse-source-search'; import {LighthouseSourceMetadata} from '../../models/lighthouse/lighthouse-source-metadata'; +import {SourceListItem} from '../medical-sources/medical-sources.component'; -export class SourceListItem { - source?: Source - metadata: LighthouseSourceMetadata -} @Component({ selector: 'app-explore', @@ -33,12 +30,19 @@ export class ExploreComponent implements OnInit { //handle connected sources sources const connectedSources = results as Source[] - forkJoin(connectedSources.map((source) => this.lighthouseApi.getLighthouseSource(source.endpoint_id))).subscribe((connectedMetadata) => { - for(const ndx in connectedSources){ - this.connectedSources.push({source: connectedSources[ndx], metadata: connectedMetadata[ndx]}) + forkJoin(connectedSources.map((source) => { + //TODO: remove this, and similar code in medical-sources-card.component.ts + if(source.platform_type == 'fasten' || source.platform_type == 'manual') { + return this.lighthouseApi.getLighthouseCatalogBrand(source.platform_type) + } else { + return of(null) } - this.loading = false - }) + })).subscribe((connectedMetadata) => { + for(const ndx in connectedSources){ + this.connectedSources.push({source: connectedSources[ndx], brand: connectedMetadata[ndx]}) + } + this.loading = false + }) if(connectedSources.length == 0) this.loading = false }, error => {