diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportDataCollation.java b/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportDataCollation.java index 73913bffa..3c000e3fc 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportDataCollation.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportDataCollation.java @@ -26,12 +26,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.UUID; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.Set; -import java.util.HashMap; +import java.util.*; import java.time.LocalDate; import java.time.Month; import java.nio.ByteBuffer; @@ -222,28 +217,27 @@ public ReportHours getReportHours() { private List getFeedbackType(FeedbackType type) { List feedback = new ArrayList(); + ReviewPeriod reviewPeriod = reviewPeriodServices.findById(reviewPeriodId); // Get the list of requests for the member and review period. // We will need to cross-reference the templates. LocalDateRange dateRange = getDateRange(); List requests = feedbackRequestServices.findByValues(null, memberId, null, - null, null, null, null); - + reviewPeriod.getPeriodStartDate().toLocalDate(), null, null, null); + List filtered = new LinkedList<>(); // Iterate over each request and find the template. Determine the purpose // of the template. - ReviewPeriod reviewPeriod = reviewPeriodServices.findById(reviewPeriodId); Map templates = new HashMap(); for (FeedbackRequest request: requests) { // Make sure we haven't already considered this template. // Also, require that the request either be directly associated with // our review period or that the request was submitted within the time // range of our review period. - if (!templates.containsKey(request.getTemplateId()) && - ((request.getReviewPeriodId() != null && + if ((request.getReviewPeriodId() != null && request.getReviewPeriodId().equals(reviewPeriod.getId())) || - (request.getSubmitDate() != null && - dateInRange(request.getSubmitDate(), dateRange.start, - dateRange.end)))) { + (request.getStatus().equalsIgnoreCase("submitted") && + request.getSendDate() != null && + request.getSendDate().isBefore(reviewPeriod.getCloseDate().toLocalDate()))) { try { FeedbackTemplate template = feedbackTemplateServices.getById(request.getTemplateId()); @@ -260,13 +254,14 @@ private List getFeedbackType(FeedbackType type) { reviewPeriod.getReviewTemplateId()); break; case FeedbackType.feedback: - use = !template.getIsReview() && request.getStatus().equalsIgnoreCase("submitted") && - request.getSendDate() != null && request.getSendDate().isAfter(reviewPeriod.getPeriodStartDate().toLocalDate()) && - request.getSendDate().isBefore(reviewPeriod.getCloseDate().toLocalDate()); + use = !template.getIsReview(); break; } if (use) { - templates.put(template.getId(), template.getTitle()); + filtered.add(request); + if(!templates.containsKey(template.getId())) { + templates.put(template.getId(), template.getTitle()); + } } } catch(NotFoundException ex) { LOG.error(ex.toString()); @@ -280,7 +275,7 @@ private List getFeedbackType(FeedbackType type) { String templateTitle = templates.get(templateId); List feedbackAnswers = new ArrayList(); - for (FeedbackRequest request: requests) { + for (FeedbackRequest request: filtered) { if (request.getTemplateId().equals(templateId)) { UUID recipientId = request.getRecipientId(); MemberProfile recipient = memberProfileServices.getById(