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 --- 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); } } 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())); }