From 1018409c403c2dd4f76df761dd38e5aec84495a5 Mon Sep 17 00:00:00 2001 From: Eraxyso <130852025+Eraxyso@users.noreply.github.com> Date: Fri, 8 Nov 2024 02:17:41 +0000 Subject: [PATCH 1/2] fix: delete function in handler for result --- handler/questionnaire.go | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/handler/questionnaire.go b/handler/questionnaire.go index 7e7c0741..15f7bcf7 100644 --- a/handler/questionnaire.go +++ b/handler/questionnaire.go @@ -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) -} From 9a438ca78f7af25f4e426335555e523b1ca0d108 Mon Sep 17 00:00:00 2001 From: Eraxyso <130852025+Eraxyso@users.noreply.github.com> Date: Fri, 8 Nov 2024 02:28:05 +0000 Subject: [PATCH 2/2] fix: update usage of Response.Respondent to handle its type change to nullable --- controller/adapter.go | 2 +- controller/questionnaire.go | 2 +- controller/response.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/controller/adapter.go b/controller/adapter.go index 4284a385..44794d72 100644 --- a/controller/adapter.go +++ b/controller/adapter.go @@ -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, } diff --git a/controller/questionnaire.go b/controller/questionnaire.go index f36d2bfc..2341e42b 100644 --- a/controller/questionnaire.go +++ b/controller/questionnaire.go @@ -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, diff --git a/controller/response.go b/controller/response.go index e344f968..346f548e 100644 --- a/controller/response.go +++ b/controller/response.go @@ -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, }