Browse Source

Added get votes option to return only counts

block-sequence
QuickMythril 1 year ago
parent
commit
3e45948646
  1. 8
      src/main/java/org/qortal/api/resource/PollsResource.java

8
src/main/java/org/qortal/api/resource/PollsResource.java

@ -123,7 +123,7 @@ public class PollsResource {
}
)
@ApiErrors({ApiError.REPOSITORY_ISSUE})
public PollVotes getPollVotes(@PathParam("pollName") String pollName) {
public PollVotes getPollVotes(@PathParam("pollName") String pollName, @QueryParam("onlyCounts") Boolean onlyCounts) {
try (final Repository repository = RepositoryManager.getRepository()) {
PollData pollData = repository.getVotingRepository().fromPollName(pollName);
if (pollData == null)
@ -151,7 +151,11 @@ public class PollsResource {
.map(entry -> new PollVotes.OptionCount(entry.getKey(), entry.getValue()))
.collect(Collectors.toList());
return new PollVotes(votes, totalVotes, voteCounts);
if (onlyCounts != null && onlyCounts) {
return new PollVotes(null, totalVotes, voteCounts);
} else {
return new PollVotes(votes, totalVotes, voteCounts);
}
} catch (ApiException e) {
throw e;
} catch (DataException e) {

Loading…
Cancel
Save