Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 1km 이상인 거리에 대해 현재 달성한 거리를 km 단위로 수정 #266

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
}