forked from Qortal/qortal
Added get votes option to return only counts
This commit is contained in:
parent
49c0d45bc6
commit
3e45948646
@ -123,7 +123,7 @@ public class PollsResource {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ApiErrors({ApiError.REPOSITORY_ISSUE})
|
@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()) {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
PollData pollData = repository.getVotingRepository().fromPollName(pollName);
|
PollData pollData = repository.getVotingRepository().fromPollName(pollName);
|
||||||
if (pollData == null)
|
if (pollData == null)
|
||||||
@ -151,7 +151,11 @@ public class PollsResource {
|
|||||||
.map(entry -> new PollVotes.OptionCount(entry.getKey(), entry.getValue()))
|
.map(entry -> new PollVotes.OptionCount(entry.getKey(), entry.getValue()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (onlyCounts != null && onlyCounts) {
|
||||||
|
return new PollVotes(null, totalVotes, voteCounts);
|
||||||
|
} else {
|
||||||
return new PollVotes(votes, totalVotes, voteCounts);
|
return new PollVotes(votes, totalVotes, voteCounts);
|
||||||
|
}
|
||||||
} catch (ApiException e) {
|
} catch (ApiException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user