From 10054407c6c4f6a5c24e5569a331fd3a38726bf0 Mon Sep 17 00:00:00 2001 From: KoalaSat Date: Fri, 15 Mar 2024 09:27:19 +0100 Subject: [PATCH] Make it dynamic --- frontend/src/models/Exchange.model.ts | 24 +++++++++++++----------- frontend/src/models/Federation.model.ts | 6 ++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/frontend/src/models/Exchange.model.ts b/frontend/src/models/Exchange.model.ts index 0c5cfa73..5a4158a0 100644 --- a/frontend/src/models/Exchange.model.ts +++ b/frontend/src/models/Exchange.model.ts @@ -36,18 +36,20 @@ export const updateExchangeInfo = (federation: Federation): ExchangeInfo => { 'lifetime_volume', ]; - Object.values(federation.coordinators).forEach((coordinator, index) => { - if (coordinator.info !== undefined) { - premiums[index] = coordinator.info.last_day_nonkyc_btc_premium; - volumes[index] = coordinator.info.last_day_volume; - highestVersion = getHigherVer(highestVersion, coordinator.info.version); - active_robots_today = Math.max(active_robots_today, coordinator.info.active_robots_today); + Object.values(federation.coordinators) + .filter((coor) => coor.isUpdated()) + .forEach((coordinator, index) => { + if (coordinator.info !== undefined) { + premiums[index] = coordinator.info.last_day_nonkyc_btc_premium; + volumes[index] = coordinator.info.last_day_volume; + highestVersion = getHigherVer(highestVersion, coordinator.info.version); + active_robots_today = Math.max(active_robots_today, coordinator.info.active_robots_today); - aggregations.forEach((key: any) => { - info[key] = Number(info[key]) + Number(coordinator.info[key]); - }); - } - }); + aggregations.forEach((key: any) => { + info[key] = Number(info[key]) + Number(coordinator.info[key]); + }); + } + }); info.last_day_nonkyc_btc_premium = weightedMean(premiums, volumes); info.version = highestVersion; diff --git a/frontend/src/models/Federation.model.ts b/frontend/src/models/Federation.model.ts index b523b4cf..2c11659d 100644 --- a/frontend/src/models/Federation.model.ts +++ b/frontend/src/models/Federation.model.ts @@ -65,10 +65,8 @@ export class Federation { this.exchange.loadingCoordinators = this.exchange.loadingCoordinators < 1 ? 0 : this.exchange.loadingCoordinators - 1; this.loading = this.exchange.loadingCoordinators > 0; - if (Object.values(this.coordinators).every((coor) => coor.isUpdated())) { - this.updateExchange(); - this.triggerHook('onFederationUpdate'); - } + this.updateExchange(); + this.triggerHook('onFederationUpdate'); }; // Setup