Skip to content

Commit

Permalink
feat: Implement new method to retrieve contributors between dates - M…
Browse files Browse the repository at this point in the history
…EED-7455 - Meeds-io/MIPs#154 (#1738)

This PR will Implement new method to retrieve contributors between
dates.
  • Loading branch information
AzmiTouil committed Oct 9, 2024
1 parent acf822b commit c20f5bd
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,20 @@ public int countRealizationsByRuleIdAndEarnerId(String earnerIdentityId, long ru
return 0;
}
}


public List<Long> getParticipantsBetweenDates(Date fromDate, Date toDate) {
TypedQuery<Long> query = getEntityManager().createNamedQuery("RealizationEntity.getParticipantsBetweenDates", Long.class);
query.setParameter(FROM_DATE_PARAM_NAME, fromDate);
query.setParameter(TO_DATE_PARAM_NAME, toDate);
query.setParameter(EARNER_TYPE_PARAM_NAME, IdentityType.USER);
query.setParameter(STATUS_PARAM_NAME, RealizationStatus.ACCEPTED);
try {
return query.getResultList();
} catch (NoResultException e) {
return Collections.emptyList();
}
}

public long countParticipantsBetweenDates(Date fromDate, Date toDate) {
TypedQuery<Long> query = getEntityManager().createNamedQuery("RealizationEntity.countParticipantsBetweenDates", Long.class);
query.setParameter(FROM_DATE_PARAM_NAME, fromDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@
" AND g.status = :status"
)

@NamedQuery(name = "RealizationEntity.getParticipantsBetweenDates",
query = "SELECT DISTINCT g.earnerId FROM RealizationEntity g" +
" WHERE g.createdDate >= :fromDate" +
" AND g.createdDate < :toDate" +
" AND g.earnerType = :earnerType" +
" AND g.status = :status")

@Data
@EqualsAndHashCode(callSuper = true)
public class RealizationEntity extends AbstractAuditingEntity implements Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ List<RealizationDTO> cancelRealizations(String event,
*/
Map<Long, Long> getScoresByIdentityIdsAndBetweenDates(List<String> earnerIdentityIds, Date fromDate, Date toDate);

/**
* @param fromDate start of period
* @param toDate end of period
* @return List of participant users in a period of time
*/
List<Long> getParticipantsBetweenDates(Date fromDate, Date toDate);

/**
* @param fromDate start of period
* @param toDate end of period
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ public Map<Long, Long> getScoresByIdentityIdsAndBetweenDates(List<String> earner
return realizationStorage.getScoresByIdentityIdsAndBetweenDates(earnersId, fromDate, toDate);
}

@Override
public List<Long> getParticipantsBetweenDates(Date fromDate, Date toDate) {
return realizationStorage.getParticipantsBetweenDates(fromDate, toDate);
}

@Override
public long countParticipantsBetweenDates(Date fromDate, Date toDate) {
return realizationStorage.countParticipantsBetweenDates(fromDate, toDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ public int countRealizationsInPeriod(String earnerIdentityId, long ruleId, Date
return gamificationHistoryDAO.countRealizationsInPeriod(earnerIdentityId, ruleId, sinceDate);
}

public List<Long> getParticipantsBetweenDates(Date fromDate, Date toDate) {
return gamificationHistoryDAO.getParticipantsBetweenDates(fromDate, toDate);
}

public long countParticipantsBetweenDates(Date fromDate, Date toDate) {
return gamificationHistoryDAO.countParticipantsBetweenDates(fromDate, toDate);
}
Expand Down

0 comments on commit c20f5bd

Please sign in to comment.