Skip to content

Commit

Permalink
[Hot Fix] - Removed insertion of assessment in the formsdb (#98)
Browse files Browse the repository at this point in the history
* [Bug Resolve] - Multiple questions insertion in formsdb. Added indexing on columns and handled multiple assessment insertion

* [Hot Fix] - Added assessment buffer maxsize and time configurable

* [Hot Fix] - Removed insertion of assessment in the formsdb
  • Loading branch information
pankajjangid05 authored Sep 1, 2023
1 parent ca1bca0 commit cd33925
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions src/main/java/com/uci/transformer/odk/ODKConsumerReactive.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,21 +365,12 @@ public Mono<XMessage> transform(XMessage xMessage) {
}

// Save answerData => PreviousQuestion + CurrentAnswer
Mono<Pair<Boolean, List<Question>>> updateQuestionAndAssessment =
updateQuestionAndAssessment(
previousMeta,
getPreviousQuestions(
previousMeta.previousPath,
formID,
response[0].formVersion),
Mono<Pair<Boolean, List<Question>>> updateQuestionAndAssessment = updateQuestionAndAssessment(getPreviousQuestions(
previousMeta.previousPath,
formID,
transformer,
xMessage,
response[0].question,
prevQuestion,
response[0].currentIndex,
response[0].validResponse
);
response[0].formVersion),
response[0].question,
prevQuestion);


/**
Expand Down Expand Up @@ -529,7 +520,7 @@ public Mono<FormManagerParams> apply(GupshupStateEntity stateEntity) {
return Mono.just(formManagerParams);
}
})
.doOnError(e -> log.error(e.getMessage()));
.doOnError(e -> log.error("Error in getPreviousMetadata:: " + e.getMessage()));
} else {
formManagerParams.setCurrentAnswer("");
formManagerParams.setPreviousPath(prevPath);
Expand Down Expand Up @@ -560,24 +551,22 @@ private String getLocationContentText(LocationParams location) {
}

@NotNull
private Mono<Pair<Boolean, List<Question>>> updateQuestionAndAssessment(FormManagerParams previousMeta,
Mono<Pair<Boolean, List<Question>>> previousQuestions, String formID,
Transformer transformer, XMessage xMessage, Question question, Question prevQuestion,
String currentXPath, Boolean validResponse) {
private Mono<Pair<Boolean, List<Question>>> updateQuestionAndAssessment(Mono<Pair<Boolean, List<Question>>> previousQuestions, Question question, Question prevQuestion) {
return previousQuestions
.doOnNext(new Consumer<Pair<Boolean, List<Question>>>() {
@Override
public void accept(Pair<Boolean, List<Question>> existingQuestionStatus) {
if (existingQuestionStatus.getLeft()) {
log.info("updateQuestionAndAssessment::Found Question id: " + existingQuestionStatus.getRight().get(0).getId() + ", xPath: " + existingQuestionStatus.getRight().get(0).getXPath());
saveAssessmentData(existingQuestionStatus, formID, previousMeta, transformer, xMessage, null, currentXPath, validResponse);
// saveAssessmentData(existingQuestionStatus, formID, previousMeta, transformer, xMessage, null, currentXPath, validResponse);
} else {
Question saveQuestion;
if (prevQuestion == null) {
saveQuestion = question;
} else {
saveQuestion = prevQuestion;
}
log.info("updateQuestionAndAssessment::Start Saving Question : xpath : " + saveQuestion.getXPath() + " formVersion: " + saveQuestion.getFormVersion() + " formId: " + saveQuestion.getFormID());
saveQuestion(saveQuestion)
.doOnError(throwable -> {
log.error("Exception While Saving Question : " + throwable.getMessage());
Expand All @@ -586,7 +575,7 @@ public void accept(Pair<Boolean, List<Question>> existingQuestionStatus) {
@Override
public void accept(Question question) {
log.info("updateQuestionAndAssessment::Question Saved Successfully, id: " + question.getId() + ", xPath: " + question.getXPath());
saveAssessmentData(existingQuestionStatus, formID, previousMeta, transformer, xMessage, question, currentXPath, validResponse);
// saveAssessmentData(existingQuestionStatus, formID, previousMeta, transformer, xMessage, question, currentXPath, validResponse);
}
});
}
Expand Down

0 comments on commit cd33925

Please sign in to comment.