use of org.mamute.dto.SuspectMassiveVote in project mamute by caelum.
the class VoteDAO method suspectMassiveVote.
public List<SuspectMassiveVote> suspectMassiveVote(VoteType type, DateTime begin, DateTime end) {
Query query = session.createQuery("select new " + SuspectMassiveVote.class.getCanonicalName() + "(av,count(av),aa) " + "from Answer a join a.author aa join a.votes v join v.author av " + "where v.type = :type and v.createdAt between :begin and :end " + "group by av,aa " + "order by count(av) desc");
query.setParameter("type", type);
query.setParameter("begin", begin);
query.setParameter("end", end);
return query.setMaxResults(10).list();
}
use of org.mamute.dto.SuspectMassiveVote in project mamute by caelum.
the class VoteDAOTest method testName.
@Test
public void testName() throws Exception {
Question question = question(currentUser, tags);
Answer answer = answer("answer answer answer answer answer", question, currentUser);
Question question2 = question(currentUser, tags);
Answer answer2 = answer("answer answer answer answer answer", question2, currentUser);
Question question3 = question(currentUser, tags);
Answer answer3 = answer("answer answer answer answer answer", question3, currentUser);
session.save(question);
session.save(question2);
session.save(question3);
session.save(answer);
session.save(answer2);
session.save(answer3);
upvote(answer, otherUser);
upvote(answer2, otherUser);
upvote(answer3, otherUser);
List<SuspectMassiveVote> answers = votes.suspectMassiveVote(VoteType.UP, new DateTime().minusHours(1), new DateTime());
assertEquals(otherUser, answers.get(0).getVoteAuthor());
assertEquals(currentUser, answers.get(0).getAnswerAuthor());
assertEquals(3l, answers.get(0).getMassiveVoteCount().longValue());
}