From 574048eed5ff3e0f56ff4421675167000db8ce1f Mon Sep 17 00:00:00 2001 From: jramos0 Date: Fri, 3 Jul 2026 03:47:32 -0600 Subject: [PATCH 1/3] Fix update accelerator dashboard stats in real time #6601 --- .../acceleration-stats.component.ts | 38 +++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/components/acceleration/acceleration-stats/acceleration-stats.component.ts b/frontend/src/app/components/acceleration/acceleration-stats/acceleration-stats.component.ts index fad1bc7b9..ddfc5351e 100644 --- a/frontend/src/app/components/acceleration/acceleration-stats/acceleration-stats.component.ts +++ b/frontend/src/app/components/acceleration/acceleration-stats/acceleration-stats.component.ts @@ -1,6 +1,7 @@ import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit } from '@angular/core'; -import { Observable } from 'rxjs'; +import { BehaviorSubject, EMPTY, Observable, merge, catchError, debounceTime, distinctUntilChanged, filter, switchMap, tap } from 'rxjs'; import { ServicesApiServices } from '@app/services/services-api.service'; +import { StateService } from '@app/services/state.service'; export type AccelerationStats = { totalRequested: number; @@ -21,21 +22,44 @@ export class AccelerationStatsComponent implements OnInit, OnChanges { @Input() timespan: '24h' | '1m' | '1y' | 'all' = '1y'; accelerationStats$: Observable; blocksInPeriod: number = 7 * 144; + private timespan$ = new BehaviorSubject<'24h' | '1m' | '1y' | 'all'>( + this.timespan + ); constructor( - private servicesApiService: ServicesApiServices - ) { } + private servicesApiService: ServicesApiServices, + private stateService: StateService + ) {} ngOnInit(): void { - this.updateStats(); + const websocketRefresh$ = this.stateService.accelerations$.pipe( + filter( + (delta) => + !delta.reset && (!!delta.added.length || !!delta.removed.length) + ), + debounceTime(2000) + ); + + this.accelerationStats$ = merge( + this.timespan$.pipe(tap(() => this.updateBlocksInPeriod())), + websocketRefresh$, + this.stateService.chainTip$.pipe(distinctUntilChanged()) + ).pipe( + switchMap(() => + this.servicesApiService + .getAccelerationStats$({ timeframe: this.timespan }) + .pipe( + catchError(() => EMPTY) + ) + ) + ); } ngOnChanges(): void { - this.updateStats(); + this.timespan$.next(this.timespan); } - updateStats(): void { - this.accelerationStats$ = this.servicesApiService.getAccelerationStats$({ timeframe: this.timespan }); + private updateBlocksInPeriod(): void { switch (this.timespan) { case '24h': this.blocksInPeriod = 144; From 457b0e6ffae66a8d74ffe75471cef7dc95fb5145 Mon Sep 17 00:00:00 2001 From: jramos0 Date: Fri, 3 Jul 2026 04:18:15 -0600 Subject: [PATCH 2/3] Adding debounceTime --- .../acceleration-stats/acceleration-stats.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/app/components/acceleration/acceleration-stats/acceleration-stats.component.ts b/frontend/src/app/components/acceleration/acceleration-stats/acceleration-stats.component.ts index ddfc5351e..9735055c4 100644 --- a/frontend/src/app/components/acceleration/acceleration-stats/acceleration-stats.component.ts +++ b/frontend/src/app/components/acceleration/acceleration-stats/acceleration-stats.component.ts @@ -45,6 +45,7 @@ export class AccelerationStatsComponent implements OnInit, OnChanges { websocketRefresh$, this.stateService.chainTip$.pipe(distinctUntilChanged()) ).pipe( + debounceTime(0), switchMap(() => this.servicesApiService .getAccelerationStats$({ timeframe: this.timespan }) From ec74c3472d2d87d38488bdad3b7f0d8614f182b9 Mon Sep 17 00:00:00 2001 From: jramos0 Date: Fri, 3 Jul 2026 04:49:47 -0600 Subject: [PATCH 3/3] Changing debounce to throttle --- .../acceleration-stats/acceleration-stats.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/components/acceleration/acceleration-stats/acceleration-stats.component.ts b/frontend/src/app/components/acceleration/acceleration-stats/acceleration-stats.component.ts index 9735055c4..7eb26ce23 100644 --- a/frontend/src/app/components/acceleration/acceleration-stats/acceleration-stats.component.ts +++ b/frontend/src/app/components/acceleration/acceleration-stats/acceleration-stats.component.ts @@ -1,5 +1,5 @@ import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit } from '@angular/core'; -import { BehaviorSubject, EMPTY, Observable, merge, catchError, debounceTime, distinctUntilChanged, filter, switchMap, tap } from 'rxjs'; +import { BehaviorSubject, EMPTY, Observable, merge, catchError, debounceTime, distinctUntilChanged, filter, switchMap, tap, throttleTime } from 'rxjs'; import { ServicesApiServices } from '@app/services/services-api.service'; import { StateService } from '@app/services/state.service'; @@ -37,7 +37,7 @@ export class AccelerationStatsComponent implements OnInit, OnChanges { (delta) => !delta.reset && (!!delta.added.length || !!delta.removed.length) ), - debounceTime(2000) + throttleTime(2000) ); this.accelerationStats$ = merge(