Skip to content

Commit

Permalink
server: Fixed formatting of StatisticsService
Browse files Browse the repository at this point in the history
  • Loading branch information
vhurryharry committed Sep 21, 2020
1 parent 727a103 commit 49c417b
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions server/app/com/xsn/explorer/services/StatisticsService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand All @@ -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
Expand Down

0 comments on commit 49c417b

Please sign in to comment.