@Test public void testExecute() { final Long streamScopeId = 87433L; Assert.assertEquals(new Long(3L), sut.execute(new UsageMetricDailyStreamInfoRequest(new Date(), streamScopeId))); }
@Override public Long execute(final UsageMetricDailyStreamInfoRequest inRequest) { Query activityQuery, commentQuery; HashSet<String> peopleIds = new HashSet<String>(); activityQuery = getEntityManager() .createQuery( "SELECT DISTINCT(actorId) FROM Activity WHERE actorType=:actorType " + "AND recipientStreamScope.id = :recipientStreamScopeId AND postedTime < :reportDate") .setParameter("actorType", EntityType.PERSON) .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()) .setParameter("reportDate", DateDayExtractor.getEndOfDay(inRequest.getMetricsDate())); commentQuery = getEntityManager() .createQuery( "SELECT DISTINCT(author.accountId) FROM Comment " + "WHERE target.recipientStreamScope.id = :recipientStreamScopeId " + "AND timeSent < :reportDate") .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()) .setParameter("reportDate", DateDayExtractor.getEndOfDay(inRequest.getMetricsDate())); peopleIds.addAll(activityQuery.getResultList()); peopleIds.addAll(commentQuery.getResultList()); return new Long(peopleIds.size()); }
GetTotalStreamContributorCountDbMapper extends
        BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, Long> { @Override public Long execute(final UsageMetricDailyStreamInfoRequest inRequest) { Query activityQuery, commentQuery; HashSet<String> peopleIds = new HashSet<String>(); activityQuery = getEntityManager() .createQuery( "SELECT DISTINCT(actorId) FROM Activity WHERE actorType=:actorType " + "AND recipientStreamScope.id = :recipientStreamScopeId AND postedTime < :reportDate") .setParameter("actorType", EntityType.PERSON) .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()) .setParameter("reportDate", DateDayExtractor.getEndOfDay(inRequest.getMetricsDate())); commentQuery = getEntityManager() .createQuery( "SELECT DISTINCT(author.accountId) FROM Comment " + "WHERE target.recipientStreamScope.id = :recipientStreamScopeId " + "AND timeSent < :reportDate") .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()) .setParameter("reportDate", DateDayExtractor.getEndOfDay(inRequest.getMetricsDate())); peopleIds.addAll(activityQuery.getResultList()); peopleIds.addAll(commentQuery.getResultList()); return new Long(peopleIds.size()); } }
GetTotalStreamContributorCountDbMapper extends
        BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, Long> { @Override public Long execute(final UsageMetricDailyStreamInfoRequest inRequest) { Query activityQuery, commentQuery; HashSet<String> peopleIds = new HashSet<String>(); activityQuery = getEntityManager() .createQuery( "SELECT DISTINCT(actorId) FROM Activity WHERE actorType=:actorType " + "AND recipientStreamScope.id = :recipientStreamScopeId AND postedTime < :reportDate") .setParameter("actorType", EntityType.PERSON) .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()) .setParameter("reportDate", DateDayExtractor.getEndOfDay(inRequest.getMetricsDate())); commentQuery = getEntityManager() .createQuery( "SELECT DISTINCT(author.accountId) FROM Comment " + "WHERE target.recipientStreamScope.id = :recipientStreamScopeId " + "AND timeSent < :reportDate") .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()) .setParameter("reportDate", DateDayExtractor.getEndOfDay(inRequest.getMetricsDate())); peopleIds.addAll(activityQuery.getResultList()); peopleIds.addAll(commentQuery.getResultList()); return new Long(peopleIds.size()); }  }
GetTotalStreamContributorCountDbMapper extends
        BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, Long> { @Override public Long execute(final UsageMetricDailyStreamInfoRequest inRequest) { Query activityQuery, commentQuery; HashSet<String> peopleIds = new HashSet<String>(); activityQuery = getEntityManager() .createQuery( "SELECT DISTINCT(actorId) FROM Activity WHERE actorType=:actorType " + "AND recipientStreamScope.id = :recipientStreamScopeId AND postedTime < :reportDate") .setParameter("actorType", EntityType.PERSON) .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()) .setParameter("reportDate", DateDayExtractor.getEndOfDay(inRequest.getMetricsDate())); commentQuery = getEntityManager() .createQuery( "SELECT DISTINCT(author.accountId) FROM Comment " + "WHERE target.recipientStreamScope.id = :recipientStreamScopeId " + "AND timeSent < :reportDate") .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()) .setParameter("reportDate", DateDayExtractor.getEndOfDay(inRequest.getMetricsDate())); peopleIds.addAll(activityQuery.getResultList()); peopleIds.addAll(commentQuery.getResultList()); return new Long(peopleIds.size()); }  @Override Long execute(final UsageMetricDailyStreamInfoRequest inRequest); }
GetTotalStreamContributorCountDbMapper extends
        BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, Long> { @Override public Long execute(final UsageMetricDailyStreamInfoRequest inRequest) { Query activityQuery, commentQuery; HashSet<String> peopleIds = new HashSet<String>(); activityQuery = getEntityManager() .createQuery( "SELECT DISTINCT(actorId) FROM Activity WHERE actorType=:actorType " + "AND recipientStreamScope.id = :recipientStreamScopeId AND postedTime < :reportDate") .setParameter("actorType", EntityType.PERSON) .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()) .setParameter("reportDate", DateDayExtractor.getEndOfDay(inRequest.getMetricsDate())); commentQuery = getEntityManager() .createQuery( "SELECT DISTINCT(author.accountId) FROM Comment " + "WHERE target.recipientStreamScope.id = :recipientStreamScopeId " + "AND timeSent < :reportDate") .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()) .setParameter("reportDate", DateDayExtractor.getEndOfDay(inRequest.getMetricsDate())); peopleIds.addAll(activityQuery.getResultList()); peopleIds.addAll(commentQuery.getResultList()); return new Long(peopleIds.size()); }  @Override Long execute(final UsageMetricDailyStreamInfoRequest inRequest);  }