1 | package org.cardanofoundation.explorer.api.controller; | |
2 | ||
3 | import jakarta.validation.Valid; | |
4 | ||
5 | import lombok.RequiredArgsConstructor; | |
6 | ||
7 | import org.springframework.data.domain.Sort; | |
8 | import org.springframework.http.ResponseEntity; | |
9 | import org.springframework.validation.annotation.Validated; | |
10 | import org.springframework.web.bind.annotation.GetMapping; | |
11 | import org.springframework.web.bind.annotation.PathVariable; | |
12 | import org.springframework.web.bind.annotation.RequestMapping; | |
13 | import org.springframework.web.bind.annotation.RequestParam; | |
14 | import org.springframework.web.bind.annotation.RestController; | |
15 | ||
16 | import io.swagger.v3.oas.annotations.Operation; | |
17 | import io.swagger.v3.oas.annotations.Parameter; | |
18 | import io.swagger.v3.oas.annotations.tags.Tag; | |
19 | import org.springdoc.core.annotations.ParameterObject; | |
20 | ||
21 | import org.cardanofoundation.explorer.api.config.LogMessage; | |
22 | import org.cardanofoundation.explorer.api.model.request.governanceAction.GovCommitteeHistoryFilter; | |
23 | import org.cardanofoundation.explorer.api.model.request.governanceAction.GovernanceActionFilter; | |
24 | import org.cardanofoundation.explorer.api.model.request.governanceAction.GovernanceActionRequest; | |
25 | import org.cardanofoundation.explorer.api.model.request.governanceAction.VoteFilter; | |
26 | import org.cardanofoundation.explorer.api.model.response.BaseFilterResponse; | |
27 | import org.cardanofoundation.explorer.api.model.response.governanceAction.*; | |
28 | import org.cardanofoundation.explorer.api.service.GovernanceActionService; | |
29 | import org.cardanofoundation.explorer.common.entity.enumeration.VoterType; | |
30 | import org.cardanofoundation.explorer.common.validation.pagination.Pagination; | |
31 | import org.cardanofoundation.explorer.common.validation.pagination.PaginationDefault; | |
32 | import org.cardanofoundation.explorer.common.validation.pagination.PaginationValid; | |
33 | ||
34 | @RestController | |
35 | @RequestMapping("/api/v1/gov-actions") | |
36 | @RequiredArgsConstructor | |
37 | @Validated | |
38 | @Tag(name = "gov-actions", description = "The governance action APIs") | |
39 | public class GovernanceActionController { | |
40 | ||
41 | private final GovernanceActionService governanceActionService; | |
42 | ||
43 | @GetMapping("overview") | |
44 | @LogMessage | |
45 | @Operation( | |
46 | summary = "Get governance overview", | |
47 | tags = {"gov-actions"}) | |
48 | public ResponseEntity<GovernanceOverviewResponse> getGovOverview() { | |
49 |
1
1. getGovOverview : replaced return value with null for org/cardanofoundation/explorer/api/controller/GovernanceActionController::getGovOverview → KILLED |
return ResponseEntity.ok(governanceActionService.getGovernanceOverview()); |
50 | } | |
51 | ||
52 | @GetMapping("{voterHash}") | |
53 | @LogMessage | |
54 | @Operation( | |
55 | summary = "Get governance action that vote by voter hash", | |
56 | tags = {"gov-actions"}) | |
57 | public ResponseEntity<BaseFilterResponse<GovernanceActionResponse>> | |
58 | getGovActionByVoterHashAndFilter( | |
59 | @PathVariable @Parameter(description = "The Voter Hash") String voterHash, | |
60 | @ParameterObject GovernanceActionFilter governanceActionFilter, | |
61 | @ParameterObject | |
62 | @PaginationValid | |
63 | @PaginationDefault( | |
64 | size = 20, | |
65 | sort = {"blockTime"}, | |
66 | direction = Sort.Direction.DESC) | |
67 | @Valid | |
68 | Pagination pagination) { | |
69 |
1
1. getGovActionByVoterHashAndFilter : replaced return value with null for org/cardanofoundation/explorer/api/controller/GovernanceActionController::getGovActionByVoterHashAndFilter → KILLED |
return ResponseEntity.ok( |
70 | governanceActionService.getGovernanceActions( | |
71 | voterHash, governanceActionFilter, pagination.toPageable())); | |
72 | } | |
73 | ||
74 | @GetMapping | |
75 | @LogMessage | |
76 | @Operation( | |
77 | summary = "Get governance action by filter", | |
78 | tags = {"gov-actions"}) | |
79 | public ResponseEntity<BaseFilterResponse<GovernanceActionResponse>> getGovActionByFilter( | |
80 | @ParameterObject GovernanceActionFilter governanceActionFilter, | |
81 | @ParameterObject | |
82 | @PaginationValid | |
83 | @PaginationDefault( | |
84 | size = 20, | |
85 | sort = {"blockTime"}, | |
86 | direction = Sort.Direction.DESC) | |
87 | @Valid | |
88 | Pagination pagination) { | |
89 |
1
1. getGovActionByFilter : replaced return value with null for org/cardanofoundation/explorer/api/controller/GovernanceActionController::getGovActionByFilter → NO_COVERAGE |
return ResponseEntity.ok( |
90 | governanceActionService.getGovernanceActions( | |
91 | null, governanceActionFilter, pagination.toPageable())); | |
92 | } | |
93 | ||
94 | @GetMapping("committee-history") | |
95 | @LogMessage | |
96 | @Operation( | |
97 | summary = "Get governance action committee history by filter", | |
98 | tags = {"gov-actions"}) | |
99 | public ResponseEntity<BaseFilterResponse<GovernanceActionResponse>> | |
100 | getGovActionCommitteeHistoryByFilter( | |
101 | @ParameterObject GovCommitteeHistoryFilter govCommitteeHistoryFilter, | |
102 | @ParameterObject | |
103 | @PaginationValid | |
104 | @PaginationDefault( | |
105 | size = 20, | |
106 | sort = {"blockTime"}, | |
107 | direction = Sort.Direction.DESC) | |
108 | @Valid | |
109 | Pagination pagination) { | |
110 |
1
1. getGovActionCommitteeHistoryByFilter : replaced return value with null for org/cardanofoundation/explorer/api/controller/GovernanceActionController::getGovActionCommitteeHistoryByFilter → NO_COVERAGE |
return ResponseEntity.ok( |
111 | governanceActionService.getGovCommitteeStatusHistory( | |
112 | govCommitteeHistoryFilter, pagination.toPageable())); | |
113 | } | |
114 | ||
115 | @GetMapping("{voterHash}/voting-procedure-detail") | |
116 | @LogMessage | |
117 | @Operation( | |
118 | summary = "Get governance action that vote by voter hash", | |
119 | tags = {"gov-actions"}) | |
120 | public ResponseEntity<GovernanceActionDetailsResponse> getGovActionByTxHashAndVoterHash( | |
121 | @PathVariable @Parameter(description = "The voterHash") String voterHash, | |
122 | @ParameterObject GovernanceActionRequest governanceActionRequest) { | |
123 |
1
1. getGovActionByTxHashAndVoterHash : replaced return value with null for org/cardanofoundation/explorer/api/controller/GovernanceActionController::getGovActionByTxHashAndVoterHash → KILLED |
return ResponseEntity.ok( |
124 | governanceActionService.getGovernanceActionDetails(voterHash, governanceActionRequest)); | |
125 | } | |
126 | ||
127 | @GetMapping("voting-chart") | |
128 | @LogMessage | |
129 | @Operation( | |
130 | summary = "Get voting chart of governance action", | |
131 | tags = {"gov-actions"}) | |
132 | public ResponseEntity<VotingChartResponse> getVotingChartByGovAction( | |
133 | @RequestParam @Parameter(description = "The tx hash of governance action") String txHash, | |
134 | @RequestParam @Parameter(description = "The index of governance action") Integer index, | |
135 | @RequestParam @Parameter(description = "The type of voter") VoterType voterType) { | |
136 |
1
1. getVotingChartByGovAction : replaced return value with null for org/cardanofoundation/explorer/api/controller/GovernanceActionController::getVotingChartByGovAction → KILLED |
return ResponseEntity.ok( |
137 | governanceActionService.getVotingChartByGovActionTxHashAndIndex(txHash, index, voterType)); | |
138 | } | |
139 | ||
140 | @GetMapping("/{txHash}/{index}") | |
141 | @LogMessage | |
142 | @Operation( | |
143 | summary = "Get governance action details", | |
144 | tags = {"gov-actions"}) | |
145 | public ResponseEntity<GovernanceActionOverViewResponse> getGovActionDetails( | |
146 | @PathVariable @Parameter(description = "The hash of transaction governance action") | |
147 | String txHash, | |
148 | @PathVariable @Parameter(description = "The index of transaction governance action") | |
149 | Integer index) { | |
150 |
1
1. getGovActionDetails : replaced return value with null for org/cardanofoundation/explorer/api/controller/GovernanceActionController::getGovActionDetails → KILLED |
return ResponseEntity.ok( |
151 | governanceActionService.getGovernanceActionOverviewResponse(txHash, index)); | |
152 | } | |
153 | ||
154 | @GetMapping("/authors") | |
155 | @LogMessage | |
156 | @Operation( | |
157 | summary = "Get authors who create governance action", | |
158 | tags = {"gov-actions"}) | |
159 | public ResponseEntity<BaseFilterResponse<AuthorResponse>> getAuthorsByAnchorUrlAndAnchorHash( | |
160 | @RequestParam @Parameter(description = "The anchor url of transaction governance action") | |
161 | String anchorUrl, | |
162 | @RequestParam @Parameter(description = "The anchor hash of transaction governance action") | |
163 | String anchorHash, | |
164 | @ParameterObject | |
165 | @PaginationValid | |
166 | @PaginationDefault( | |
167 | size = 6, | |
168 | sort = {"name"}, | |
169 | direction = Sort.Direction.ASC) | |
170 | @Valid | |
171 | Pagination pagination) { | |
172 |
1
1. getAuthorsByAnchorUrlAndAnchorHash : replaced return value with null for org/cardanofoundation/explorer/api/controller/GovernanceActionController::getAuthorsByAnchorUrlAndAnchorHash → KILLED |
return ResponseEntity.ok( |
173 | governanceActionService.getAuthorsByAnchor(anchorUrl, anchorHash, pagination.toPageable())); | |
174 | } | |
175 | ||
176 | @GetMapping("/votes") | |
177 | @LogMessage | |
178 | @Operation( | |
179 | summary = "Get voting on governance action", | |
180 | tags = {"gov-actions"}) | |
181 | public ResponseEntity<BaseFilterResponse<VotingOnGovActionResponse>> getVotesOnGovAction( | |
182 | @ParameterObject VoteFilter voteFilter, | |
183 | @ParameterObject | |
184 | @PaginationValid | |
185 | @PaginationDefault( | |
186 | size = 3, | |
187 | sort = {"blockTime"}, | |
188 | direction = Sort.Direction.DESC) | |
189 | @Valid | |
190 | Pagination pagination) { | |
191 |
1
1. getVotesOnGovAction : replaced return value with null for org/cardanofoundation/explorer/api/controller/GovernanceActionController::getVotesOnGovAction → KILLED |
return ResponseEntity.ok( |
192 | governanceActionService.getVotingOnGovAction(voteFilter, pagination.toPageable())); | |
193 | } | |
194 | ||
195 | @GetMapping("/{txHash}/{index}/votes/range-values") | |
196 | @LogMessage | |
197 | @Operation( | |
198 | summary = "Get range value to filter on votes overview section", | |
199 | tags = {"gov-actions"}) | |
200 | public ResponseEntity<RangeFilterVoteResponse> getRangeFilterForVoteSection( | |
201 | @PathVariable @Parameter(description = "The hash of transaction governance action") | |
202 | String txHash, | |
203 | @PathVariable @Parameter(description = "The index of transaction governance action") | |
204 | Integer index) { | |
205 |
1
1. getRangeFilterForVoteSection : replaced return value with null for org/cardanofoundation/explorer/api/controller/GovernanceActionController::getRangeFilterForVoteSection → KILLED |
return ResponseEntity.ok(governanceActionService.getRangeFilterVoteResponse(txHash, index)); |
206 | } | |
207 | } | |
Mutations | ||
49 |
1.1 |
|
69 |
1.1 |
|
89 |
1.1 |
|
110 |
1.1 |
|
123 |
1.1 |
|
136 |
1.1 |
|
150 |
1.1 |
|
172 |
1.1 |
|
191 |
1.1 |
|
205 |
1.1 |