Skip to content

Commit

Permalink
Merge pull request #2773 from objectcomputing/bugfix-2769/take-two-an…
Browse files Browse the repository at this point in the history
…d-feedback-restriction

Took a slightly different approach to filtering feedback on the merit…
  • Loading branch information
mkimberlin authored Nov 14, 2024
2 parents a41349f + a671998 commit 7db850a
Showing 1 changed file with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -222,28 +217,27 @@ public ReportHours getReportHours() {
private List<Feedback> getFeedbackType(FeedbackType type) {
List<Feedback> feedback = new ArrayList<Feedback>();

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<FeedbackRequest> requests =
feedbackRequestServices.findByValues(null, memberId, null,
null, null, null, null);

reviewPeriod.getPeriodStartDate().toLocalDate(), null, null, null);
List<FeedbackRequest> filtered = new LinkedList<>();
// Iterate over each request and find the template. Determine the purpose
// of the template.
ReviewPeriod reviewPeriod = reviewPeriodServices.findById(reviewPeriodId);
Map<UUID, String> templates = new HashMap<UUID, String>();
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());
Expand All @@ -260,13 +254,14 @@ private List<Feedback> 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());
Expand All @@ -280,7 +275,7 @@ private List<Feedback> getFeedbackType(FeedbackType type) {
String templateTitle = templates.get(templateId);
List<Feedback.Answer> feedbackAnswers =
new ArrayList<Feedback.Answer>();
for (FeedbackRequest request: requests) {
for (FeedbackRequest request: filtered) {
if (request.getTemplateId().equals(templateId)) {
UUID recipientId = request.getRecipientId();
MemberProfile recipient = memberProfileServices.getById(
Expand Down

0 comments on commit 7db850a

Please sign in to comment.