Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adjustments in handling logic due to schema changes #1282

Merged
merged 2 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controller/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func respondentDetail2Response(ctx echo.Context, respondentDetail model.Responde
IsDraft: respondentDetail.SubmittedAt.Valid,
ModifiedAt: respondentDetail.ModifiedAt,
QuestionnaireId: respondentDetail.QuestionnaireID,
Respondent: respondentDetail.TraqID,
Respondent: &respondentDetail.TraqID,
ResponseId: respondentDetail.ResponseID,
SubmittedAt: respondentDetail.SubmittedAt.Time,
}
Expand Down
2 changes: 1 addition & 1 deletion controller/questionnaire.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ func (q Questionnaire) PostQuestionnaireResponse(c echo.Context, questionnaireID
res = openapi.Response{
QuestionnaireId: questionnaireID,
ResponseId: resopnseID,
Respondent: userID,
Respondent: &userID,
SubmittedAt: submittedAt,
ModifiedAt: modifiedAt,
IsDraft: params.IsDraft,
Expand Down
2 changes: 1 addition & 1 deletion controller/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (r Response) GetMyResponses(ctx echo.Context, params openapi.GetMyResponses
ModifiedAt: response.ModifiedAt,
QuestionnaireId: response.QuestionnaireId,
QuestionnaireInfo: &questionnaireInfo,
Respondent: userID,
Respondent: &userID,
ResponseId: response.ResponseId,
SubmittedAt: response.SubmittedAt,
}
Expand Down
22 changes: 0 additions & 22 deletions handler/questionnaire.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,25 +188,3 @@ func (h Handler) PostQuestionnaireResponse(ctx echo.Context, questionnaireID ope

return ctx.JSON(201, res)
}

// (GET /questionnaires/{questionnaireID}/result)
func (h Handler) GetQuestionnaireResult(ctx echo.Context, questionnaireID openapi.QuestionnaireIDInPath) error {
res := openapi.Result{}
userID, err := getUserID(ctx)
if err != nil {
ctx.Logger().Errorf("failed to get userID: %+v", err)
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("failed to get userID: %w", err))
}

q := controller.NewQuestionnaire()
res, err = q.GetQuestionnaireResult(ctx, questionnaireID, userID)
if err != nil {
if errors.Is(err, echo.ErrNotFound) {
return echo.NewHTTPError(http.StatusNotFound, fmt.Errorf("questionnaire result not found: %w", err))
}
ctx.Logger().Errorf("failed to get questionnaire result: %+v", err)
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("failed to get questionnaire result: %w", err))
}

return ctx.JSON(200, res)
}
Loading