From d7b614a6804018ddeb1665bcd0ba245624daa77d Mon Sep 17 00:00:00 2001 From: Jason Yoo Date: Thu, 22 Feb 2024 21:16:12 +0900 Subject: [PATCH] [Feat] add default negative feedback (#45) --- src/handler/feedback.handler.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/handler/feedback.handler.go b/src/handler/feedback.handler.go index d6a75f5..e499093 100644 --- a/src/handler/feedback.handler.go +++ b/src/handler/feedback.handler.go @@ -84,6 +84,7 @@ func (handler *FeedbackHandlerImpl) GetPronunciationFeedback(c echo.Context) err } transcript := firstToUpper(feedbackResponse.GetTranscript()) + negativeFeedback := getNegativeFeedbackOrDefault(feedbackResponse.GetNegativeFeedback()) result := pb.GetPronunciationFeedbackResponse{ PronunciationFeedback: &pb.PronunciationFeedbackDTO{ @@ -94,7 +95,7 @@ func (handler *FeedbackHandlerImpl) GetPronunciationFeedback(c echo.Context) err VolumeScore: feedbackResponse.GetVolumeScore(), SpeedScore: feedbackResponse.GetSpeedScore(), PositiveFeedback: feedbackResponse.GetPositiveFeedback(), - NegativeFeedback: feedbackResponse.GetNegativeFeedback(), + NegativeFeedback: negativeFeedback, }, } @@ -157,12 +158,13 @@ func (handler *FeedbackHandlerImpl) GetCommunicationFeedback(c echo.Context) err log.Printf("grpc request failed: %v", err) return model.NewCustomHTTPError(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError)) } + negativeFeedback := getNegativeFeedbackOrDefault(response.GetNegativeFeedback()) result := pb.GetCommunicationFeedbackResponse{ CommunicationFeedback: &pb.CommunicationFeedbackDTO{ SceneId: request.GetSceneId(), PositiveFeedback: response.GetPositiveFeedback(), - NegativeFeedback: response.GetNegativeFeedback(), + NegativeFeedback: negativeFeedback, EnhancedAnswer: response.GetEnhancedAnswer(), }, } @@ -209,6 +211,13 @@ func firstToUpper(s string) string { return string(unicode.ToUpper(r)) + lowerCase[size:] } +func getNegativeFeedbackOrDefault(negativeFeedback string) string { + if negativeFeedback == "" { + return "Nothing to improve. Great job!" + } + return negativeFeedback +} + func FeedbackHandlerInit(sentenceService service.SentenceService, sceneService service.SceneService, storageService service.StorageService) *FeedbackHandlerImpl { return &FeedbackHandlerImpl{ sentenceService: sentenceService,