1 | package org.cardanofoundation.explorer.api.service.impl; | |
2 | ||
3 | import java.util.Objects; | |
4 | ||
5 | import lombok.RequiredArgsConstructor; | |
6 | import lombok.extern.log4j.Log4j2; | |
7 | ||
8 | import org.springframework.beans.factory.annotation.Value; | |
9 | import org.springframework.data.redis.core.RedisTemplate; | |
10 | import org.springframework.stereotype.Service; | |
11 | ||
12 | import org.cardanofoundation.explorer.api.common.constant.CommonConstant; | |
13 | import org.cardanofoundation.explorer.api.mapper.PoolMapper; | |
14 | import org.cardanofoundation.explorer.api.model.response.pool.PoolRangeValuesResponse; | |
15 | import org.cardanofoundation.explorer.api.model.response.pool.StakePoolsChartResponse; | |
16 | import org.cardanofoundation.explorer.api.projection.PoolRangeProjection; | |
17 | import org.cardanofoundation.explorer.api.repository.ledgersync.EpochRepository; | |
18 | import org.cardanofoundation.explorer.api.repository.ledgersync.PoolHashRepository; | |
19 | import org.cardanofoundation.explorer.api.repository.ledgersync.PoolUpdateRepository; | |
20 | import org.cardanofoundation.explorer.api.service.FetchRewardDataService; | |
21 | import org.cardanofoundation.explorer.api.service.PoolService; | |
22 | ||
23 | @Service | |
24 | @RequiredArgsConstructor | |
25 | @Log4j2 | |
26 | public class PoolServiceImpl implements PoolService { | |
27 | ||
28 | private final FetchRewardDataService fetchRewardDataService; | |
29 | ||
30 | private final PoolHashRepository poolHashRepository; | |
31 | ||
32 | private final EpochRepository epochRepository; | |
33 | ||
34 | private final PoolMapper poolMapper; | |
35 | ||
36 | private final RedisTemplate<String, Integer> redisTemplate; | |
37 | ||
38 | private final PoolUpdateRepository poolUpdateRepository; | |
39 | ||
40 | @Value("${application.network}") | |
41 | String network; | |
42 | ||
43 | @Override | |
44 | public PoolRangeValuesResponse getPoolRangeValues() { | |
45 | boolean isKoiOs = fetchRewardDataService.useKoios(); | |
46 | Integer epochNo = epochRepository.findCurrentEpochNo().orElse(CommonConstant.ZERO); | |
47 | PoolRangeProjection projection; | |
48 |
1
1. getPoolRangeValues : negated conditional → KILLED |
if (isKoiOs) { |
49 | projection = poolHashRepository.getPoolRangeWithUsingKoi0s(epochNo); | |
50 | } else { | |
51 | projection = poolHashRepository.getPoolRangeWithoutUsingKoi0s(); | |
52 | } | |
53 |
1
1. getPoolRangeValues : replaced return value with null for org/cardanofoundation/explorer/api/service/impl/PoolServiceImpl::getPoolRangeValues → KILLED |
return poolMapper.fromPoolRangeProjection(projection); |
54 | } | |
55 | ||
56 | @Override | |
57 | public StakePoolsChartResponse getStakePoolsChart() { | |
58 | Integer currentEpoch = epochRepository.findCurrentEpochNo().orElseThrow(); | |
59 | ||
60 | Long registered = | |
61 | Objects.requireNonNull( | |
62 | redisTemplate.opsForValue().get(CommonConstant.REDIS_POOL_ACTIVATE + network)) | |
63 | .longValue(); | |
64 | ||
65 | Long active = poolUpdateRepository.getNumberOfActivePool(currentEpoch); | |
66 | ||
67 |
1
1. getStakePoolsChart : replaced return value with null for org/cardanofoundation/explorer/api/service/impl/PoolServiceImpl::getStakePoolsChart → KILLED |
return StakePoolsChartResponse.builder().registeredPool(registered).activePool(active).build(); |
68 | } | |
69 | } | |
Mutations | ||
48 |
1.1 |
|
53 |
1.1 |
|
67 |
1.1 |