diff --git a/server/app/com/xsn/explorer/services/StatisticsService.scala b/server/app/com/xsn/explorer/services/StatisticsService.scala index 6ec3c396..3641fbc1 100644 --- a/server/app/com/xsn/explorer/services/StatisticsService.scala +++ b/server/app/com/xsn/explorer/services/StatisticsService.scala @@ -7,7 +7,11 @@ import com.alexitc.playsonify.core.FutureOr.Implicits._ import com.xsn.explorer.data.async.{StatisticsFutureDataHandler, BalanceFutureDataHandler} import com.xsn.explorer.models.{MarketStatistics, StatisticsDetails, NodeStatistics, SynchronizationProgress} import com.xsn.explorer.tasks.CurrencySynchronizerActor -import com.xsn.explorer.services.synchronizer.repository.{MasternodeRepository, MerchantnodeRepository, NodeStatsRepository} +import com.xsn.explorer.services.synchronizer.repository.{ + MasternodeRepository, + MerchantnodeRepository, + NodeStatsRepository +} import javax.inject.Inject import org.scalactic.{Bad, Good} import akka.util.Timeout @@ -53,8 +57,15 @@ class StatisticsService @Inject()( tposProtocols <- merchantnodeRepository.getProtocols() coinsStaking <- nodeStatsRepository.getCoinsStaking() } yield { - val stats = NodeStatistics(masternodes = mnCount, enabledMasternodes = mnEnabledCount, masternodesProtocols = mnProtocols, - tposnodes = tposCount, enabledTposnodes = tposEnabledCount, tposnodesProtocols = tposProtocols, coinsStaking = coinsStaking) + val stats = NodeStatistics( + masternodes = mnCount, + enabledMasternodes = mnEnabledCount, + masternodesProtocols = mnProtocols, + tposnodes = tposCount, + enabledTposnodes = tposEnabledCount, + tposnodesProtocols = tposProtocols, + coinsStaking = coinsStaking + ) Good(stats) } } @@ -65,7 +76,10 @@ class StatisticsService @Inject()( val result = for { tposNodesList <- tposNodes.map(x => Good(x)).toFutureOr - tposAddressList <- tposNodesList.map(t => t.payee).map(statisticsFutureDataHandler.getTPoSMerchantStakingAddresses).toFutureOr + tposAddressList <- tposNodesList + .map(t => t.payee) + .map(statisticsFutureDataHandler.getTPoSMerchantStakingAddresses) + .toFutureOr coinsStaking <- tposAddressList.flatten.map(balanceFutureDataHandler.getBy).toFutureOr coinsStakingSum = coinsStaking.map(t => t.available).sum } yield coinsStakingSum