From c91a64518052cc66b299d88aaa501ff2e917d161 Mon Sep 17 00:00:00 2001 From: Ahn Jiwan Date: Wed, 8 Nov 2023 23:36:10 +0900 Subject: [PATCH 1/3] =?UTF-8?q?:bug:=20fix:=20=EB=88=84=EB=9D=BD=EB=90=9C?= =?UTF-8?q?=20=EA=B8=B0=EC=A4=80=20=EC=98=81=EC=96=91=EC=84=AD=EC=B7=A8?= =?UTF-8?q?=EB=9F=89=20=EC=B6=94=EA=B0=80=20(#60)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../food/dto/ResponseNutritionSumByDateDto.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/diareat/diareat/food/dto/ResponseNutritionSumByDateDto.java b/src/main/java/com/diareat/diareat/food/dto/ResponseNutritionSumByDateDto.java index 1520eb4..ea6be33 100644 --- a/src/main/java/com/diareat/diareat/food/dto/ResponseNutritionSumByDateDto.java +++ b/src/main/java/com/diareat/diareat/food/dto/ResponseNutritionSumByDateDto.java @@ -1,5 +1,6 @@ package com.diareat.diareat.food.dto; +import com.diareat.diareat.user.domain.BaseNutrition; import lombok.AllArgsConstructor; import lombok.Getter; @@ -23,7 +24,14 @@ public class ResponseNutritionSumByDateDto { double ratioProtein; double ratioFat; - public static ResponseNutritionSumByDateDto of (Long userId, LocalDate checkDate, int nutritionSumType, int totalKcal, int totalCarbohydrate, int totalProtein, int totalFat, double ratioKcal, double ratioCarbohydrate, double ratioProtein, double ratioFat){ - return new ResponseNutritionSumByDateDto(userId, checkDate, nutritionSumType, totalKcal, totalCarbohydrate, totalProtein, totalFat, ratioKcal, ratioCarbohydrate, ratioProtein, ratioFat); + BaseNutrition baseNutrition; + + public static ResponseNutritionSumByDateDto of (Long userId, LocalDate checkDate, int nutritionSumType, int totalKcal, + int totalCarbohydrate, int totalProtein, int totalFat, double ratioKcal, + double ratioCarbohydrate, double ratioProtein, double ratioFat, + BaseNutrition baseNutrition){ + return new ResponseNutritionSumByDateDto(userId, checkDate, nutritionSumType, totalKcal, + totalCarbohydrate, totalProtein, totalFat, ratioKcal, + ratioCarbohydrate, ratioProtein, ratioFat, baseNutrition); } } From 38bd92fb1ed124fbd2c35f6972ccb2384c0daec2 Mon Sep 17 00:00:00 2001 From: Ahn Jiwan Date: Wed, 8 Nov 2023 23:36:43 +0900 Subject: [PATCH 2/3] =?UTF-8?q?:white=5Fcheck=5Fmark:=20test:=20=EA=B8=B0?= =?UTF-8?q?=EC=A4=80=20=EC=98=81=EC=96=91=EC=84=AD=EC=B7=A8=EB=9F=89=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EB=B0=8F=20=EA=B2=80=EC=A6=9D=20=EC=99=84=EB=A3=8C=20(#60)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../diareat/diareat/food/service/FoodService.java | 4 +++- .../diareat/controller/FoodControllerTest.java | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/diareat/diareat/food/service/FoodService.java b/src/main/java/com/diareat/diareat/food/service/FoodService.java index 824baed..9e9a315 100644 --- a/src/main/java/com/diareat/diareat/food/service/FoodService.java +++ b/src/main/java/com/diareat/diareat/food/service/FoodService.java @@ -368,7 +368,9 @@ private ResponseNutritionSumByDateDto calculateNutritionSumAndRatio(Long userId, double ratioProtein = Math.round((((double) totalProtein / (double) targetUser.getBaseNutrition().getProtein()) * 100.0) * 10.0) / 10.0; double ratioFat = Math.round((((double) totalFat / (double) targetUser.getBaseNutrition().getFat()) * 100.0) * 10.0) / 10.0; - return ResponseNutritionSumByDateDto.of(userId, checkDate, nutritionSumType, totalKcal, totalCarbohydrate, totalProtein, totalFat, ratioKcal, ratioCarbohydrate, ratioProtein, ratioFat); + return ResponseNutritionSumByDateDto.of(userId, checkDate, nutritionSumType, totalKcal, + totalCarbohydrate, totalProtein, totalFat, ratioKcal, + ratioCarbohydrate, ratioProtein, ratioFat, targetUser.getBaseNutrition()); } private void validateUser(Long userId) { diff --git a/src/test/java/com/diareat/diareat/controller/FoodControllerTest.java b/src/test/java/com/diareat/diareat/controller/FoodControllerTest.java index c902b01..413d53f 100644 --- a/src/test/java/com/diareat/diareat/controller/FoodControllerTest.java +++ b/src/test/java/com/diareat/diareat/controller/FoodControllerTest.java @@ -254,7 +254,8 @@ void testGetNutritionSumByDate() throws Exception{ //Given LocalDate date = LocalDate.now(); ResponseNutritionSumByDateDto responseNutritionSumByDateDto = ResponseNutritionSumByDateDto.of(testUserId,date,1 - ,500,100,50,50,0.2,0.3,0.4,0.5); + ,500,100,50,50,0.2,0.3,0.4,0.5, + BaseNutrition.createNutrition(500,100,50,50)); ApiResponse expectedResponse = ApiResponse.success(responseNutritionSumByDateDto,ResponseCode.FOOD_READ_SUCCESS.getMessage()); when(foodService.getNutritionSumByDate(any(Long.class),any(LocalDate.class))).thenReturn(responseNutritionSumByDateDto); @@ -279,6 +280,7 @@ void testGetNutritionSumByDate() throws Exception{ .andExpect(MockMvcResultMatchers.jsonPath("$.data.ratioCarbohydrate").value(expectedResponse.getData().getRatioCarbohydrate())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.ratioProtein").value(expectedResponse.getData().getRatioProtein())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.ratioFat").value(expectedResponse.getData().getRatioFat())) + .andExpect(MockMvcResultMatchers.jsonPath("$.data.baseNutrition.carbohydrate").value(expectedResponse.getData().getBaseNutrition().getCarbohydrate())) .andExpect(MockMvcResultMatchers.jsonPath("$.msg").value(expectedResponse.getMsg())); } @@ -290,7 +292,8 @@ void testGetNutritionSumByWeek() throws Exception { //Given LocalDate date = LocalDate.now(); ResponseNutritionSumByDateDto responseNutritionSumByDateDto = ResponseNutritionSumByDateDto.of(testUserId, date, 7 - , 500, 100, 50, 50, 0.2, 0.3, 0.4, 0.5); + , 500, 100, 50, 50, 0.2, 0.3, 0.4, 0.5, + BaseNutrition.createNutrition(500, 100, 50, 50)); ApiResponse expectedResponse = ApiResponse.success(responseNutritionSumByDateDto, ResponseCode.FOOD_READ_SUCCESS.getMessage()); when(foodService.getNutritionSumByWeek(any(Long.class))).thenReturn(responseNutritionSumByDateDto); @@ -312,6 +315,7 @@ void testGetNutritionSumByWeek() throws Exception { .andExpect(MockMvcResultMatchers.jsonPath("$.data.ratioCarbohydrate").value(expectedResponse.getData().getRatioCarbohydrate())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.ratioProtein").value(expectedResponse.getData().getRatioProtein())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.ratioFat").value(expectedResponse.getData().getRatioFat())) + .andExpect(MockMvcResultMatchers.jsonPath("$.data.baseNutrition.carbohydrate").value(expectedResponse.getData().getBaseNutrition().getCarbohydrate())) .andExpect(MockMvcResultMatchers.jsonPath("$.msg").value(expectedResponse.getMsg())); } @@ -323,7 +327,8 @@ void testGetNutritionSumByMonth() throws Exception { //Given LocalDate date = LocalDate.now(); ResponseNutritionSumByDateDto responseNutritionSumByDateDto = ResponseNutritionSumByDateDto.of(testUserId, date, 30 - , 500, 100, 50, 50, 0.2, 0.3, 0.4, 0.5); + , 500, 100, 50, 50, 0.2, 0.3, 0.4, 0.5, + BaseNutrition.createNutrition(500, 100, 50, 50)); ApiResponse expectedResponse = ApiResponse.success(responseNutritionSumByDateDto, ResponseCode.FOOD_READ_SUCCESS.getMessage()); when(foodService.getNutritionSumByMonth(any(Long.class))).thenReturn(responseNutritionSumByDateDto); @@ -345,6 +350,7 @@ void testGetNutritionSumByMonth() throws Exception { .andExpect(MockMvcResultMatchers.jsonPath("$.data.ratioCarbohydrate").value(expectedResponse.getData().getRatioCarbohydrate())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.ratioProtein").value(expectedResponse.getData().getRatioProtein())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.ratioFat").value(expectedResponse.getData().getRatioFat())) + .andExpect(MockMvcResultMatchers.jsonPath("$.data.baseNutrition.carbohydrate").value(expectedResponse.getData().getBaseNutrition().getCarbohydrate())) .andExpect(MockMvcResultMatchers.jsonPath("$.msg").value(expectedResponse.getMsg())); } From d8c27fababbcf312bdd051cb8c733189dfcbfe7c Mon Sep 17 00:00:00 2001 From: Ahn Jiwan Date: Wed, 8 Nov 2023 23:37:21 +0900 Subject: [PATCH 3/3] =?UTF-8?q?:construction=5Fworker:=20chore:=20?= =?UTF-8?q?=EC=A7=80=EB=82=98=EC=B9=98=EA=B2=8C=20=EB=8A=90=EB=A6=B0=20?= =?UTF-8?q?=EC=86=8D=EB=8F=84=EB=A1=9C=20=EC=9D=B8=ED=95=B4=20CPU=20?= =?UTF-8?q?=EB=A6=AC=EC=86=8C=EC=8A=A4=20=ED=95=A0=EB=8B=B9=EB=9F=89=20?= =?UTF-8?q?=EC=A6=9D=EA=B0=80=20(#60)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- k8s/manifest.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k8s/manifest.yaml b/k8s/manifest.yaml index 090d421..56a083c 100644 --- a/k8s/manifest.yaml +++ b/k8s/manifest.yaml @@ -24,14 +24,14 @@ spec: resources: limits: memory: "512Mi" - cpu: 0.3 + cpu: 0.5 ports: - containerPort: 8080 readinessProbe: httpGet: path: /swagger-ui/index.html port: 8080 - initialDelaySeconds: 30 + initialDelaySeconds: 40 periodSeconds: 5 failureThreshold: 24 ---