1 | package org.cardanofoundation.explorer.api.controller; | |
2 | ||
3 | import java.util.List; | |
4 | ||
5 | import jakarta.validation.Valid; | |
6 | ||
7 | import lombok.RequiredArgsConstructor; | |
8 | ||
9 | import org.springframework.data.domain.Sort; | |
10 | import org.springframework.http.ResponseEntity; | |
11 | import org.springframework.validation.annotation.Validated; | |
12 | import org.springframework.web.bind.annotation.GetMapping; | |
13 | import org.springframework.web.bind.annotation.PathVariable; | |
14 | import org.springframework.web.bind.annotation.RequestMapping; | |
15 | import org.springframework.web.bind.annotation.RequestParam; | |
16 | import org.springframework.web.bind.annotation.RestController; | |
17 | ||
18 | import io.swagger.v3.oas.annotations.Operation; | |
19 | import io.swagger.v3.oas.annotations.Parameter; | |
20 | import io.swagger.v3.oas.annotations.tags.Tag; | |
21 | import org.springdoc.core.annotations.ParameterObject; | |
22 | ||
23 | import org.cardanofoundation.explorer.api.common.constant.CommonConstant; | |
24 | import org.cardanofoundation.explorer.api.config.LogMessage; | |
25 | import org.cardanofoundation.explorer.api.model.request.pool.PoolListFilter; | |
26 | import org.cardanofoundation.explorer.api.model.response.BaseFilterResponse; | |
27 | import org.cardanofoundation.explorer.api.model.response.DelegationResponse; | |
28 | import org.cardanofoundation.explorer.api.model.response.PoolDetailDelegatorResponse; | |
29 | import org.cardanofoundation.explorer.api.model.response.pool.DelegationHeaderResponse; | |
30 | import org.cardanofoundation.explorer.api.model.response.pool.PoolDetailEpochResponse; | |
31 | import org.cardanofoundation.explorer.api.model.response.pool.PoolDetailHeaderResponse; | |
32 | import org.cardanofoundation.explorer.api.model.response.pool.PoolResponse; | |
33 | import org.cardanofoundation.explorer.api.model.response.pool.chart.PoolDetailAnalyticsResponse; | |
34 | import org.cardanofoundation.explorer.api.service.DelegationService; | |
35 | import org.cardanofoundation.explorer.common.entity.ledgersync.Delegation_; | |
36 | import org.cardanofoundation.explorer.common.validation.length.LengthValid; | |
37 | import org.cardanofoundation.explorer.common.validation.pagination.Pagination; | |
38 | import org.cardanofoundation.explorer.common.validation.pagination.PaginationDefault; | |
39 | import org.cardanofoundation.explorer.common.validation.pagination.PaginationValid; | |
40 | ||
41 | @RestController | |
42 | @RequestMapping("/api/v1/delegations") | |
43 | @RequiredArgsConstructor | |
44 | @Validated | |
45 | @Tag(name = "delegation", description = "The delegation APIs") | |
46 | public class DelegationController { | |
47 | ||
48 | private final DelegationService delegationService; | |
49 | ||
50 | @GetMapping | |
51 | @LogMessage | |
52 | @Operation( | |
53 | summary = "List delegations", | |
54 | tags = {"delegation"}) | |
55 | public ResponseEntity<BaseFilterResponse<DelegationResponse>> getDelegations( | |
56 | @ParameterObject | |
57 | @PaginationValid | |
58 | @PaginationDefault( | |
59 | size = 20, | |
60 | sort = {Delegation_.TX_ID}, | |
61 | direction = Sort.Direction.DESC) | |
62 | @Valid | |
63 | Pagination pagination) { | |
64 |
1
1. getDelegations : replaced return value with null for org/cardanofoundation/explorer/api/controller/DelegationController::getDelegations → KILLED |
return ResponseEntity.ok(delegationService.getDelegations(pagination.toPageable())); |
65 | } | |
66 | ||
67 | @GetMapping("/header") | |
68 | @LogMessage | |
69 | @Operation( | |
70 | summary = "Get data for delegation header", | |
71 | tags = {"delegation"}) | |
72 | public ResponseEntity<DelegationHeaderResponse> getDataForDelegationHeader() { | |
73 |
1
1. getDataForDelegationHeader : replaced return value with null for org/cardanofoundation/explorer/api/controller/DelegationController::getDataForDelegationHeader → KILLED |
return ResponseEntity.ok(delegationService.getDataForDelegationHeader()); |
74 | } | |
75 | ||
76 | @GetMapping("/pool-list") | |
77 | @LogMessage | |
78 | @Operation( | |
79 | summary = "Get data for pool list", | |
80 | tags = {"delegation"}) | |
81 | public ResponseEntity<BaseFilterResponse<PoolResponse>> getDataForPoolTable( | |
82 | @ParameterObject @PaginationValid @Valid Pagination pagination, | |
83 | @ParameterObject @Parameter(description = "The filter for pool") PoolListFilter filter) { | |
84 |
1
1. getDataForPoolTable : replaced return value with null for org/cardanofoundation/explorer/api/controller/DelegationController::getDataForPoolTable → KILLED |
return ResponseEntity.ok( |
85 | delegationService.getDataForPoolTable(pagination.toPageable(), filter)); | |
86 | } | |
87 | ||
88 | @GetMapping("/pool-detail-header/{poolViewOrHash}") | |
89 | @LogMessage | |
90 | @Operation( | |
91 | summary = "Get data for pool detail header", | |
92 | tags = {"delegation"}) | |
93 | public ResponseEntity<PoolDetailHeaderResponse> getDataForPoolDetail( | |
94 | @PathVariable | |
95 | @LengthValid(CommonConstant.POOL_VIEW_LENGTH) | |
96 | @Parameter(description = "The Bech32 encoding of the pool hash.") | |
97 | String poolViewOrHash) { | |
98 |
1
1. getDataForPoolDetail : replaced return value with null for org/cardanofoundation/explorer/api/controller/DelegationController::getDataForPoolDetail → KILLED |
return ResponseEntity.ok(delegationService.getDataForPoolDetail(poolViewOrHash)); |
99 | } | |
100 | ||
101 | @GetMapping("/pool-detail-analytics") | |
102 | @LogMessage | |
103 | @Operation( | |
104 | summary = "Get analytics for pool detail", | |
105 | tags = {"delegation"}) | |
106 | public ResponseEntity<PoolDetailAnalyticsResponse> getAnalyticsForPoolDetail( | |
107 | @RequestParam("poolView") | |
108 | @LengthValid(CommonConstant.POOL_VIEW_LENGTH) | |
109 | @Parameter(description = "The Bech32 encoding of the pool hash.") | |
110 | String poolViewOrHash) { | |
111 |
1
1. getAnalyticsForPoolDetail : replaced return value with null for org/cardanofoundation/explorer/api/controller/DelegationController::getAnalyticsForPoolDetail → KILLED |
return ResponseEntity.ok(delegationService.getAnalyticsForPoolDetail(poolViewOrHash)); |
112 | } | |
113 | ||
114 | @GetMapping("/pool-detail-epochs") | |
115 | @LogMessage | |
116 | @Operation( | |
117 | summary = "Get epochs for pool detail", | |
118 | tags = {"delegation"}) | |
119 | public ResponseEntity<BaseFilterResponse<PoolDetailEpochResponse>> getEpochListForPoolDetail( | |
120 | @RequestParam("poolView") | |
121 | @LengthValid(CommonConstant.POOL_VIEW_LENGTH) | |
122 | @Parameter(description = "The Bech32 encoding of the pool hash.") | |
123 | String poolViewOrHash, | |
124 | @ParameterObject @PaginationValid @Valid Pagination pagination) { | |
125 |
1
1. getEpochListForPoolDetail : replaced return value with null for org/cardanofoundation/explorer/api/controller/DelegationController::getEpochListForPoolDetail → KILLED |
return ResponseEntity.ok( |
126 | delegationService.getEpochListForPoolDetail(pagination.toPageable(), poolViewOrHash)); | |
127 | } | |
128 | ||
129 | @GetMapping("/pool-detail-delegators") | |
130 | @LogMessage | |
131 | @Operation( | |
132 | summary = "Get delegators for pool detail", | |
133 | tags = {"delegation"}) | |
134 | public ResponseEntity<BaseFilterResponse<PoolDetailDelegatorResponse>> getDelegatorForPoolDetail( | |
135 | @RequestParam("poolView") | |
136 | @LengthValid(CommonConstant.POOL_VIEW_LENGTH) | |
137 | @Parameter(description = "The Bech32 encoding of the pool hash.") | |
138 | String poolViewOrHash, | |
139 | @ParameterObject @PaginationValid @Valid Pagination pagination) { | |
140 |
1
1. getDelegatorForPoolDetail : replaced return value with null for org/cardanofoundation/explorer/api/controller/DelegationController::getDelegatorForPoolDetail → KILLED |
return ResponseEntity.ok( |
141 | delegationService.getDelegatorsForPoolDetail(pagination.toPageable(), poolViewOrHash)); | |
142 | } | |
143 | ||
144 | @GetMapping("/top") | |
145 | @LogMessage | |
146 | @Operation( | |
147 | summary = "Find Top(default is 3) Delegation Pool order by pool size", | |
148 | tags = {"delegation"}) | |
149 | public ResponseEntity<List<PoolResponse>> findTopDelegationPool( | |
150 | @ParameterObject @PaginationValid @Valid Pagination pagination) { | |
151 |
1
1. findTopDelegationPool : replaced return value with null for org/cardanofoundation/explorer/api/controller/DelegationController::findTopDelegationPool → KILLED |
return ResponseEntity.ok(delegationService.findTopDelegationPool(pagination.toPageable())); |
152 | } | |
153 | } | |
Mutations | ||
64 |
1.1 |
|
73 |
1.1 |
|
84 |
1.1 |
|
98 |
1.1 |
|
111 |
1.1 |
|
125 |
1.1 |
|
140 |
1.1 |
|
151 |
1.1 |