mirror of
https://github.com/mempool/mempool.git
synced 2026-08-13 12:33:11 +02:00
Merge pull request #6613 from jramos0/stats-accelerator-dashboard
Some checks are pending
Backend Integration Tests with MariaDB / Backend Integration Tests - node 24.13.0 (push) Waiting to run
CI Pipeline for the Backend and Frontend / Backend (dev) - node 24.13.0 (push) Waiting to run
CI Pipeline for the Backend and Frontend / Backend (prod) - node 24.13.0 (push) Waiting to run
CI Pipeline for the Backend and Frontend / Cache assets for builds (push) Waiting to run
CI Pipeline for the Backend and Frontend / Frontend (dev) - node 24.13.0 (push) Blocked by required conditions
CI Pipeline for the Backend and Frontend / Frontend (prod) - node 24.13.0 (push) Blocked by required conditions
CI Pipeline for the Backend and Frontend / E2E tests for liquid (push) Blocked by required conditions
CI Pipeline for the Backend and Frontend / E2E tests for mempool (push) Blocked by required conditions
CI Pipeline for the Backend and Frontend / E2E tests for testnet4 (push) Blocked by required conditions
CI Pipeline for the Backend and Frontend / Validate generated backend Docker JSON (push) Waiting to run
Supply Chain Audit / Backend install-script audit (push) Waiting to run
Supply Chain Audit / Frontend install-script audit (push) Waiting to run
Some checks are pending
Backend Integration Tests with MariaDB / Backend Integration Tests - node 24.13.0 (push) Waiting to run
CI Pipeline for the Backend and Frontend / Backend (dev) - node 24.13.0 (push) Waiting to run
CI Pipeline for the Backend and Frontend / Backend (prod) - node 24.13.0 (push) Waiting to run
CI Pipeline for the Backend and Frontend / Cache assets for builds (push) Waiting to run
CI Pipeline for the Backend and Frontend / Frontend (dev) - node 24.13.0 (push) Blocked by required conditions
CI Pipeline for the Backend and Frontend / Frontend (prod) - node 24.13.0 (push) Blocked by required conditions
CI Pipeline for the Backend and Frontend / E2E tests for liquid (push) Blocked by required conditions
CI Pipeline for the Backend and Frontend / E2E tests for mempool (push) Blocked by required conditions
CI Pipeline for the Backend and Frontend / E2E tests for testnet4 (push) Blocked by required conditions
CI Pipeline for the Backend and Frontend / Validate generated backend Docker JSON (push) Waiting to run
Supply Chain Audit / Backend install-script audit (push) Waiting to run
Supply Chain Audit / Frontend install-script audit (push) Waiting to run
Stats accelerator dashboard
This commit is contained in:
commit
01207ceb7b
1 changed files with 32 additions and 7 deletions
|
|
@ -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, throttleTime } 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,45 @@ export class AccelerationStatsComponent implements OnInit, OnChanges {
|
|||
@Input() timespan: '24h' | '1m' | '1y' | 'all' = '1y';
|
||||
accelerationStats$: Observable<AccelerationStats>;
|
||||
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)
|
||||
),
|
||||
throttleTime(2000)
|
||||
);
|
||||
|
||||
this.accelerationStats$ = merge(
|
||||
this.timespan$.pipe(tap(() => this.updateBlocksInPeriod())),
|
||||
websocketRefresh$,
|
||||
this.stateService.chainTip$.pipe(distinctUntilChanged())
|
||||
).pipe(
|
||||
debounceTime(0),
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue