Skip to content

Commit

Permalink
Fix: 1km 이상인 거리에 대해 현재 달성한 거리를 km 단위로 수정 (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaewon-pro authored Oct 15, 2024
1 parent 3f12475 commit 91fe935
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.dnd.runus.presentation.v1.scale.dto;

import static com.dnd.runus.global.constant.MetricsConversionFactor.METERS_IN_A_KILOMETER;

import io.swagger.v3.oas.annotations.media.Schema;

import java.text.DecimalFormat;
import java.time.LocalDate;
import java.util.List;

import static com.dnd.runus.global.constant.MetricsConversionFactor.METERS_IN_A_KILOMETER;

public record ScaleCoursesResponse(
Info info,
List<AchievedCourse> achievedCourses,
Expand Down Expand Up @@ -53,7 +53,7 @@ public record CurrentCourse(
String name,
@Schema(description = "현재 코스 총 거리", example = "200km")
String totalDistance,
@Schema(description = "현재 달성한 거리, 현재 50m 달성", example = "50m")
@Schema(description = "현재 달성한 거리, 현재 32.3km 달성", example = "32.3km")
String achievedDistance,
@Schema(description = "현재 코스 설명 메시지", example = "대전까지 100km 남았어요!")
String message
Expand All @@ -64,7 +64,14 @@ public CurrentCourse(
int achievedMeter,
String message
) {
this(name, KILO_METER_FORMATTER.format(totalMeter / METERS_IN_A_KILOMETER), achievedMeter + "m", message);
this(name, KILO_METER_FORMATTER.format(totalMeter / METERS_IN_A_KILOMETER), formatAchievedDistance(achievedMeter), message);
}

private static String formatAchievedDistance(int achievedMeter) {
if (achievedMeter < METERS_IN_A_KILOMETER) {
return achievedMeter + "m";
}
return KILO_METER_FORMATTER.format(achievedMeter / METERS_IN_A_KILOMETER);
}
}
}

0 comments on commit 91fe935

Please sign in to comment.