Mercurial > hg > ugly-duckling
diff src/app/services/feature-extraction/feature-extraction.service.ts @ 305:75a234459d3b
Fix for changes to streaming api in piper-js i.e. collect on the client
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Fri, 12 May 2017 08:28:18 +0100 |
parents | 7a6ef711c73a |
children | 98490d0ceb77 |
line wrap: on
line diff
--- a/src/app/services/feature-extraction/feature-extraction.service.ts Fri May 12 08:26:18 2017 +0100 +++ b/src/app/services/feature-extraction/feature-extraction.service.ts Fri May 12 08:28:18 2017 +0100 @@ -14,6 +14,7 @@ WebWorkerStreamingClient } from 'piper/client-stubs/WebWorkerStreamingClient'; import {RequestId} from 'piper/protocols/WebWorkerProtocol'; +import {collect, StreamingConfiguration} from "piper/StreamingService"; type RepoUri = string; export interface AvailableLibraries { @@ -66,19 +67,24 @@ } extract(analysisItemId: string, request: SimpleRequest): Promise<void> { - return this.client.collect(request) - .do(val => { - if (val.totalBlockCount > 0) { - this.progressUpdated.next({ - id: analysisItemId, - value: (val.processedBlockCount / val.totalBlockCount) * 100 - }); - } - }) - .toPromise() - .then((response) => { - this.featuresExtracted.next(response); + let config: StreamingConfiguration; + return collect(this.client.process(request), val => { + if (val.configuration) { + config = val.configuration; + } + const progress = val.progress; + if (progress.totalBlockCount > 0) { + this.progressUpdated.next({ + id: analysisItemId, + value: (progress.processedBlockCount / progress.totalBlockCount) * 100 + }); + } + }).then(features => { + this.featuresExtracted.next({ + features: features, + outputDescriptor: config.outputDescriptor }); + }); } updateAvailableLibraries(): Observable<AvailableLibraries> {