Skip to content

Commit

Permalink
🔧 chore(feedback): Update feedback status indicators in section list
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjitm committed Feb 7, 2025
1 parent e648647 commit 22618d7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ public List<String> getAnsweredCommentByPhase(long phase) {
query.append("SELECT parent_id as parent_id,count(*) as count ");
query.append("FROM feedback_qa_comments fqc");
query.append(" WHERE id_phase=" + phase);
query.append(" and status_id = 1 ");
query.append(" and (status_id = 1 || status_id = 2 || status_id = 5) ");
query.append(" and field_id in (select id from feedback_qa_commentable_fields fqcf ");
query.append(" where section_name = 'deliverable') ");
query.append(" and reply_id is not null ");
query.append(" AND (status_id = 1 OR reply_id IS NOT NULL) ");
query.append(" group by parent_id ");

List<Map<String, Object>> rList = super.findCustomQuery(query.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ public List<String> getAnsweredCommentByPhaseToStudy(long phase) {
query.append("SELECT parent_id as parent_id,count(*) as count ");
query.append("FROM feedback_qa_comments fqc");
query.append(" WHERE id_phase=" + phase);
query.append(" and status_id = 1 ");
query.append(" and (status_id = 1 || status_id = 2 || status_id = 5)");
query.append(" and field_id in (select id from feedback_qa_commentable_fields fqcf ");
query.append(" where section_name = 'study') ");
query.append(" and reply_id is not null ");
query.append(" AND (status_id = 1 OR reply_id IS NOT NULL) ");
query.append(" group by parent_id ");

List<Map<String, Object>> rList = super.findCustomQuery(query.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,46 +223,47 @@ public void getCommentStatuses() {
List<FeedbackQACommentableFields> commentableFields = new ArrayList<>();

// get the commentable fields by sectionName
if (feedbackQACommentableFieldsManager.findAll() != null) {
commentableFields = feedbackQACommentableFieldsManager.findAll().stream()
.filter(f -> f != null && f.getSectionName().equals("study")).collect(Collectors.toList());
}
commentableFields = feedbackQACommentableFieldsManager.findBySectionName("study");

if (projectStudies != null && !projectStudies.isEmpty() && commentableFields != null
&& !commentableFields.isEmpty()) {


// Set the comment status in each project outcome
for (ProjectExpectedStudy study : projectStudies) {
int answeredComments = 0, totalComments = 0;
try {


for (FeedbackQACommentableFields commentableField : commentableFields) {
if (commentableField != null && commentableField.getId() != null) {

if (study != null && study.getId() != null && commentableField != null
&& commentableField.getId() != null) {
List<FeedbackQAComment> comments = commentManager.findAll().stream()
.filter(f -> f != null && f.getParentId() == study.getId()

List<FeedbackQAComment> comments = commentManager
.getFeedbackQACommentsByPhaseAndParentId(this.getActualPhase().getId(), study.getId()).stream()
.filter(f -> f != null

&& (f.getFeedbackStatus() != null && f.getFeedbackStatus().getId() != null && (!f
.getFeedbackStatus().getId().equals(Long.parseLong(FeedbackStatusEnum.Dismissed.getStatusId()))
// &&
// !f.getFeedbackStatus().getId().equals(Long.parseLong(FeedbackStatusEnum.Draft.getStatusId()))
))

&& f.getField() != null && f.getField().getId().equals(commentableField.getId()))
)) && f.getField() != null && f.getField().getId().equals(commentableField.getId()))
.collect(Collectors.toList());

if (comments != null && !comments.isEmpty()) {
totalComments += comments.size();
comments = comments.stream()
.filter(f -> f != null && ((f.getFeedbackStatus() != null && f.getFeedbackStatus().getId()
.equals(Long.parseLong(FeedbackStatusEnum.Agreed.getStatusId())))
|| (f.getFeedbackStatus() != null && f.getReply() != null)))
.collect(Collectors.toList());
if (comments != null) {
answeredComments += comments.size();
}
List<FeedbackQAComment> filteredComments = comments.stream().filter(f -> {
Long statusId = f.getFeedbackStatus() != null ? f.getFeedbackStatus().getId() : null;
boolean isDisagreedOrClarificationNeeded =
statusId != null && (statusId.equals(Long.valueOf(FeedbackStatusEnum.Disagreed.getStatusId()))
|| statusId.equals(Long.valueOf(FeedbackStatusEnum.ClarificatioNeeded.getStatusId())));
boolean isAgreed =
statusId != null && statusId.equals(Long.valueOf(FeedbackStatusEnum.Agreed.getStatusId()));

return (isDisagreedOrClarificationNeeded && f.getReply() != null) || isAgreed;
}).collect(Collectors.toList());

answeredComments += filteredComments.size();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,47 +349,48 @@ public void getCommentStatuses() {
List<FeedbackQACommentableFields> commentableFields = new ArrayList<>();

// get the commentable fields by sectionName
if (feedbackQACommentableFieldsManager.findAll() != null) {
commentableFields = feedbackQACommentableFieldsManager.findAll().stream()
.filter(f -> f != null && f.getSectionName().equals("innovation")).collect(Collectors.toList());
}
commentableFields = feedbackQACommentableFieldsManager.findBySectionName("innovation");

if (projectInnovations != null && !projectInnovations.isEmpty() && commentableFields != null
&& !commentableFields.isEmpty()) {


// Set the comment status in each project outcome

for (ProjectInnovation study : projectInnovations) {
int answeredComments = 0, totalComments = 0;
try {


for (FeedbackQACommentableFields commentableField : commentableFields) {
if (commentableField != null && commentableField.getId() != null) {

if (study != null && study.getId() != null && commentableField != null
&& commentableField.getId() != null) {
List<FeedbackQAComment> comments = commentManager.findAll().stream()
.filter(f -> f != null && f.getParentId() == study.getId()

List<FeedbackQAComment> comments = commentManager
.getFeedbackQACommentsByPhaseAndParentId(this.getActualPhase().getId(), study.getId()).stream()
.filter(f -> f != null

&& (f.getFeedbackStatus() != null && f.getFeedbackStatus().getId() != null && (!f
.getFeedbackStatus().getId().equals(Long.parseLong(FeedbackStatusEnum.Dismissed.getStatusId()))
// &&
// !f.getFeedbackStatus().getId().equals(Long.parseLong(FeedbackStatusEnum.Draft.getStatusId()))
))

&& f.getField() != null && f.getField().getId().equals(commentableField.getId()))
)) && f.getField() != null && f.getField().getId().equals(commentableField.getId()))
.collect(Collectors.toList());

if (comments != null && !comments.isEmpty()) {
totalComments += comments.size();
comments = comments.stream()
.filter(f -> f != null && ((f.getFeedbackStatus() != null && f.getFeedbackStatus().getId()
.equals(Long.parseLong(FeedbackStatusEnum.Agreed.getStatusId())))
|| (f.getFeedbackStatus() != null && f.getReply() != null)))
.collect(Collectors.toList());
if (comments != null) {
answeredComments += comments.size();
}
List<FeedbackQAComment> filteredComments = comments.stream().filter(f -> {
Long statusId = f.getFeedbackStatus() != null ? f.getFeedbackStatus().getId() : null;
boolean isDisagreedOrClarificationNeeded =
statusId != null && (statusId.equals(Long.valueOf(FeedbackStatusEnum.Disagreed.getStatusId()))
|| statusId.equals(Long.valueOf(FeedbackStatusEnum.ClarificatioNeeded.getStatusId())));
boolean isAgreed =
statusId != null && statusId.equals(Long.valueOf(FeedbackStatusEnum.Agreed.getStatusId()));

return (isDisagreedOrClarificationNeeded && f.getReply() != null) || isAgreed;
}).collect(Collectors.toList());

answeredComments += filteredComments.size();
}
}
}
Expand Down

0 comments on commit 22618d7

Please sign in to comment.