@Test public void debateSelfVoteDoNotCountInTotalVote() throws Exception { service.voteDebate(UP, debateId, debater, EMPTY, 20); AccountStats stats = accountDao.loadStats(debater.getUsername()); assertEquals(0, stats.getDebateDownVoted()); assertEquals(0, stats.getDebateUpVoted()); assertEquals(Optional.empty(), honorRollDao.findHonorRoll(debater.getAccountId(), zone, Instant.ofEpochMilli(debateId.epochMilli()))); }
@Override public void voteDebate(VoteState newState, FlakeId debateId, Authorization voter, VoteState previousState, long previousCount) { Debate cachedDebate = debateDao.loadDebateWithCache(debateId); ZoneInfo zoneInfo = checkVoteAuthority(cachedDebate.getZone(), voter); voteDao.voteDebate(newState, cachedDebate.getArticleId(), debateId, voter.authenticatedId(), previousState, previousCount, Instant.now()); int upVoteDelta = newState.upVoteDeltaFrom(previousState); int downVoteDelta = newState.downVoteDeltaFrom(previousState); debateDao.changeTotalVote(debateId, upVoteDelta, downVoteDelta); if (zoneInfo.canContributeVoteStats() && !voter.authenticatedId() .equals(cachedDebate.getDebaterId())) { accountDao.changeTotalVotedDebate(cachedDebate.getDebaterId(), upVoteDelta, downVoteDelta); honorRollDao.updateRotateVoteStats(HonorRollVoter.createByVote(cachedDebate, upVoteDelta, downVoteDelta)); } }
VoteServiceImpl implements VoteService { @Override public void voteDebate(VoteState newState, FlakeId debateId, Authorization voter, VoteState previousState, long previousCount) { Debate cachedDebate = debateDao.loadDebateWithCache(debateId); ZoneInfo zoneInfo = checkVoteAuthority(cachedDebate.getZone(), voter); voteDao.voteDebate(newState, cachedDebate.getArticleId(), debateId, voter.authenticatedId(), previousState, previousCount, Instant.now()); int upVoteDelta = newState.upVoteDeltaFrom(previousState); int downVoteDelta = newState.downVoteDeltaFrom(previousState); debateDao.changeTotalVote(debateId, upVoteDelta, downVoteDelta); if (zoneInfo.canContributeVoteStats() && !voter.authenticatedId() .equals(cachedDebate.getDebaterId())) { accountDao.changeTotalVotedDebate(cachedDebate.getDebaterId(), upVoteDelta, downVoteDelta); honorRollDao.updateRotateVoteStats(HonorRollVoter.createByVote(cachedDebate, upVoteDelta, downVoteDelta)); } } }
VoteServiceImpl implements VoteService { @Override public void voteDebate(VoteState newState, FlakeId debateId, Authorization voter, VoteState previousState, long previousCount) { Debate cachedDebate = debateDao.loadDebateWithCache(debateId); ZoneInfo zoneInfo = checkVoteAuthority(cachedDebate.getZone(), voter); voteDao.voteDebate(newState, cachedDebate.getArticleId(), debateId, voter.authenticatedId(), previousState, previousCount, Instant.now()); int upVoteDelta = newState.upVoteDeltaFrom(previousState); int downVoteDelta = newState.downVoteDeltaFrom(previousState); debateDao.changeTotalVote(debateId, upVoteDelta, downVoteDelta); if (zoneInfo.canContributeVoteStats() && !voter.authenticatedId() .equals(cachedDebate.getDebaterId())) { accountDao.changeTotalVotedDebate(cachedDebate.getDebaterId(), upVoteDelta, downVoteDelta); honorRollDao.updateRotateVoteStats(HonorRollVoter.createByVote(cachedDebate, upVoteDelta, downVoteDelta)); } }  }
VoteServiceImpl implements VoteService { @Override public void voteDebate(VoteState newState, FlakeId debateId, Authorization voter, VoteState previousState, long previousCount) { Debate cachedDebate = debateDao.loadDebateWithCache(debateId); ZoneInfo zoneInfo = checkVoteAuthority(cachedDebate.getZone(), voter); voteDao.voteDebate(newState, cachedDebate.getArticleId(), debateId, voter.authenticatedId(), previousState, previousCount, Instant.now()); int upVoteDelta = newState.upVoteDeltaFrom(previousState); int downVoteDelta = newState.downVoteDeltaFrom(previousState); debateDao.changeTotalVote(debateId, upVoteDelta, downVoteDelta); if (zoneInfo.canContributeVoteStats() && !voter.authenticatedId() .equals(cachedDebate.getDebaterId())) { accountDao.changeTotalVotedDebate(cachedDebate.getDebaterId(), upVoteDelta, downVoteDelta); honorRollDao.updateRotateVoteStats(HonorRollVoter.createByVote(cachedDebate, upVoteDelta, downVoteDelta)); } }  @Override List<DebateVoter> listDebateVoters(Authorization voter, FlakeId articleId); @Override void voteArticle(VoteState newState,
      FlakeId articleId,
      Authorization authorization,
      VoteState previousState,
      long previousCount); @Override void voteDebate(VoteState newState,
      FlakeId debateId,
      Authorization voter,
      VoteState previousState,
      long previousCount); @Override List<ArticleVoter> listArticleVoters(Authorization voter, List<FlakeId> articleIds); @Override List<DebateVoter> listDebateVotersByIds(Authorization voter, List<FlakeId> debateIds); @Override List<Article> listUpVotedArticles(Authorization voter, @Nullable FlakeId startArticleId); }
VoteServiceImpl implements VoteService { @Override public void voteDebate(VoteState newState, FlakeId debateId, Authorization voter, VoteState previousState, long previousCount) { Debate cachedDebate = debateDao.loadDebateWithCache(debateId); ZoneInfo zoneInfo = checkVoteAuthority(cachedDebate.getZone(), voter); voteDao.voteDebate(newState, cachedDebate.getArticleId(), debateId, voter.authenticatedId(), previousState, previousCount, Instant.now()); int upVoteDelta = newState.upVoteDeltaFrom(previousState); int downVoteDelta = newState.downVoteDeltaFrom(previousState); debateDao.changeTotalVote(debateId, upVoteDelta, downVoteDelta); if (zoneInfo.canContributeVoteStats() && !voter.authenticatedId() .equals(cachedDebate.getDebaterId())) { accountDao.changeTotalVotedDebate(cachedDebate.getDebaterId(), upVoteDelta, downVoteDelta); honorRollDao.updateRotateVoteStats(HonorRollVoter.createByVote(cachedDebate, upVoteDelta, downVoteDelta)); } }  @Override List<DebateVoter> listDebateVoters(Authorization voter, FlakeId articleId); @Override void voteArticle(VoteState newState,
      FlakeId articleId,
      Authorization authorization,
      VoteState previousState,
      long previousCount); @Override void voteDebate(VoteState newState,
      FlakeId debateId,
      Authorization voter,
      VoteState previousState,
      long previousCount); @Override List<ArticleVoter> listArticleVoters(Authorization voter, List<FlakeId> articleIds); @Override List<DebateVoter> listDebateVotersByIds(Authorization voter, List<FlakeId> debateIds); @Override List<Article> listUpVotedArticles(Authorization voter, @Nullable FlakeId startArticleId);  }