Skip to content

Commit

Permalink
Merge pull request #17 from samply/fix/resultsOverridingEachOther
Browse files Browse the repository at this point in the history
fix: collect site results and emit them each second
  • Loading branch information
torbrenner committed Jul 4, 2023
2 parents 9e4b9ab + 46aa22c commit 1733a8d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions core/src/lib/services/query.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Measure} from "../model/measure";
import {LensConfig, LENS_CONFIG_TOKEN} from "../lens-config";
import {Query} from "../model/query";
import {Condition} from "../model/condition";
import {BehaviorSubject} from "rxjs";
import {BehaviorSubject, debounceTime} from "rxjs";
import {RequestTargetFactoryService} from "./request-target-factory.service";
import {NegotiatorService} from "./negotiator.service";
import { ChipTransformPipe } from '../pipes/chip-transform.pipe';
Expand Down Expand Up @@ -51,15 +51,17 @@ export class QueryService {
})
this.configuration.requestTargets.forEach(requestTarget => {
requestTarget.isLoading$.subscribe(next => this.onRequestTargetIsLoading())
requestTarget.results$.subscribe({next : result => {
console.log(`Received results from request target ${requestTarget.key}`)
let currentResults = this.resultsSubject$.value;
result.forEach((value, key) => {
console.log(`Updated results for site ${key}`)
currentResults.set(key, value);
requestTarget.results$
.pipe(debounceTime(1000))
.subscribe({
next: result => {
let currentResults = this.resultsSubject$.value;
result.forEach((value, key) => {
currentResults.set(key, value);
})
this.resultsSubject$.next(currentResults);
}
})
this.resultsSubject$.next(currentResults);
}})
})
}

Expand Down

0 comments on commit 1733a8d

Please sign in to comment.