[accelerator] move accel stats into backend
This commit is contained in:
parent
cc06f85e73
commit
3f8a4b5119
@ -3,16 +3,16 @@
|
|||||||
<div class="item">
|
<div class="item">
|
||||||
<h5 class="card-title" i18n="accelerator.requests">Requests</h5>
|
<h5 class="card-title" i18n="accelerator.requests">Requests</h5>
|
||||||
<div class="card-text">
|
<div class="card-text">
|
||||||
<div>{{ stats.count }}</div>
|
<div>{{ stats.totalRequested }}</div>
|
||||||
<div class="symbol" i18n="accelerator.total-accelerated">accelerated</div>
|
<div class="symbol" i18n="accelerator.total-accelerated">accelerated</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<h5 class="card-title" i18n="accelerator.total-boost">Total Bid Boost</h5>
|
<h5 class="card-title" i18n="accelerator.total-boost">Total Bid Boost</h5>
|
||||||
<div class="card-text">
|
<div class="card-text">
|
||||||
<div>{{ stats.totalFeesPaid / 100_000_000 | amountShortener: 4 }} <span class="symbol" i18n="shared.btc|BTC">BTC</span></div>
|
<div>{{ stats.totalBidBoost / 100_000_000 | amountShortener: 4 }} <span class="symbol" i18n="shared.btc|BTC">BTC</span></div>
|
||||||
<span class="fiat">
|
<span class="fiat">
|
||||||
<app-fiat [value]="stats.totalFeesPaid"></app-fiat>
|
<app-fiat [value]="stats.totalBidBoost"></app-fiat>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
||||||
import { Observable, of } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { switchMap } from 'rxjs/operators';
|
import { ServicesApiServices } from '../../../services/services-api.service';
|
||||||
import { ApiService } from '../../../services/api.service';
|
|
||||||
import { StateService } from '../../../services/state.service';
|
export type AccelerationStats = {
|
||||||
import { Acceleration } from '../../../interfaces/node-api.interface';
|
totalRequested: number;
|
||||||
|
totalBidBoost: number;
|
||||||
|
successRate: number;
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-acceleration-stats',
|
selector: 'app-acceleration-stats',
|
||||||
@ -12,35 +15,13 @@ import { Acceleration } from '../../../interfaces/node-api.interface';
|
|||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class AccelerationStatsComponent implements OnInit {
|
export class AccelerationStatsComponent implements OnInit {
|
||||||
@Input() timespan: '24h' | '1w' | '1m' = '24h';
|
accelerationStats$: Observable<AccelerationStats>;
|
||||||
@Input() accelerations$: Observable<Acceleration[]>;
|
|
||||||
public accelerationStats$: Observable<any>;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private apiService: ApiService,
|
private servicesApiService: ServicesApiServices
|
||||||
private stateService: StateService,
|
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.accelerationStats$ = this.accelerations$.pipe(
|
this.accelerationStats$ = this.servicesApiService.getAccelerationStats$();
|
||||||
switchMap(accelerations => {
|
|
||||||
let totalFeesPaid = 0;
|
|
||||||
let totalSucceeded = 0;
|
|
||||||
let totalCanceled = 0;
|
|
||||||
for (const acc of accelerations) {
|
|
||||||
if (acc.status === 'completed') {
|
|
||||||
totalSucceeded++;
|
|
||||||
totalFeesPaid += (acc.feePaid - acc.baseFee - acc.vsizeFee) || 0;
|
|
||||||
} else if (acc.status === 'failed') {
|
|
||||||
totalCanceled++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return of({
|
|
||||||
count: totalSucceeded,
|
|
||||||
totalFeesPaid,
|
|
||||||
successRate: (totalSucceeded + totalCanceled > 0) ? ((totalSucceeded / (totalSucceeded + totalCanceled)) * 100) : 0.0,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<div class="card-wrapper">
|
<div class="card-wrapper">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body more-padding">
|
<div class="card-body more-padding">
|
||||||
<app-acceleration-stats timespan="1m" [accelerations$]="minedAccelerations$"></app-acceleration-stats>
|
<app-acceleration-stats timespan="1m"></app-acceleration-stats>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -60,7 +60,7 @@ export class AcceleratorDashboardComponent implements OnInit {
|
|||||||
this.accelerations$ = this.stateService.chainTip$.pipe(
|
this.accelerations$ = this.stateService.chainTip$.pipe(
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
switchMap(() => {
|
switchMap(() => {
|
||||||
return this.serviceApiServices.getAccelerationHistory$({ timeframe: '1m' }).pipe(
|
return this.serviceApiServices.getAccelerationHistory$({ timeframe: '1m', page: 1, pageLength: 100}).pipe(
|
||||||
catchError(() => {
|
catchError(() => {
|
||||||
return of([]);
|
return of([]);
|
||||||
}),
|
}),
|
||||||
@ -71,7 +71,7 @@ export class AcceleratorDashboardComponent implements OnInit {
|
|||||||
|
|
||||||
this.minedAccelerations$ = this.accelerations$.pipe(
|
this.minedAccelerations$ = this.accelerations$.pipe(
|
||||||
map(accelerations => {
|
map(accelerations => {
|
||||||
return accelerations.filter(acc => ['mined', 'completed', 'failed'].includes(acc.status));
|
return accelerations.filter(acc => ['mined', 'completed'].includes(acc.status));
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import { MenuGroup } from '../interfaces/services.interface';
|
|||||||
import { Observable, of, ReplaySubject, tap, catchError, share, filter, switchMap } from 'rxjs';
|
import { Observable, of, ReplaySubject, tap, catchError, share, filter, switchMap } from 'rxjs';
|
||||||
import { IBackendInfo } from '../interfaces/websocket.interface';
|
import { IBackendInfo } from '../interfaces/websocket.interface';
|
||||||
import { Acceleration, AccelerationHistoryParams } from '../interfaces/node-api.interface';
|
import { Acceleration, AccelerationHistoryParams } from '../interfaces/node-api.interface';
|
||||||
|
import { AccelerationStats } from '../components/acceleration/acceleration-stats/acceleration-stats.component';
|
||||||
|
|
||||||
export type ProductType = 'enterprise' | 'community' | 'mining_pool' | 'custom';
|
export type ProductType = 'enterprise' | 'community' | 'mining_pool' | 'custom';
|
||||||
export interface IUser {
|
export interface IUser {
|
||||||
@ -151,4 +152,8 @@ export class ServicesApiServices {
|
|||||||
getAccelerationHistoryObserveResponse$(params: AccelerationHistoryParams): Observable<any> {
|
getAccelerationHistoryObserveResponse$(params: AccelerationHistoryParams): Observable<any> {
|
||||||
return this.httpClient.get<any>(`${SERVICES_API_PREFIX}/accelerator/accelerations/history`, { params: { ...params }, observe: 'response'});
|
return this.httpClient.get<any>(`${SERVICES_API_PREFIX}/accelerator/accelerations/history`, { params: { ...params }, observe: 'response'});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAccelerationStats$(): Observable<AccelerationStats> {
|
||||||
|
return this.httpClient.get<AccelerationStats>(`${SERVICES_API_PREFIX}/accelerator/stats`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user