Skip to content

Commit 727bc81

Browse files
committed
refactor: 정류소 이름 변경 로직 수정
1 parent c08dc13 commit 727bc81

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

domain/src/main/java/com/stop/domain/usecase/route/GetRouteUseCaseImpl.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ internal class GetRouteUseCaseImpl @Inject constructor(
1010
private val routeRepository: RouteRepository
1111
) : GetRouteUseCase {
1212

13+
private val nameParsingRegex = """\(+[^)]+\)""".toRegex()
14+
1315
override suspend operator fun invoke(routeRequest: RouteRequest): List<Itinerary> {
1416
val originItineraries = routeRepository.getRoute(routeRequest)
1517

@@ -49,7 +51,7 @@ internal class GetRouteUseCaseImpl @Inject constructor(
4951
distance = leg.distance,
5052
end = with(leg.end) {
5153
Place(
52-
name = name.replace("(중)", ""),
54+
name = parsingName(name),
5355
coordinate = Coordinate(
5456
latitude = lat.toString(),
5557
longitude = lon.toString()
@@ -61,7 +63,7 @@ internal class GetRouteUseCaseImpl @Inject constructor(
6163
proportionOfSectionTime = calculateProportionOfSectionTime(leg.sectionTime, totalTime),
6264
start = with(leg.start) {
6365
Place(
64-
name = name.replace("(중)", ""),
66+
name = parsingName(name),
6567
coordinate = Coordinate(
6668
latitude = lat.toString(),
6769
longitude = lon.toString()
@@ -78,7 +80,7 @@ internal class GetRouteUseCaseImpl @Inject constructor(
7880
longitude = lon
7981
),
8082
stationId = stationID,
81-
stationName = stationName.replace("(중)", ""),
83+
stationName = parsingName(stationName),
8284
)
8385
}
8486
} ?: listOf(),
@@ -88,6 +90,10 @@ internal class GetRouteUseCaseImpl @Inject constructor(
8890
)
8991
}
9092

93+
private fun parsingName(originName: String): String {
94+
return originName.replace(nameParsingRegex, "")
95+
}
96+
9197
private fun calculateProportionOfSectionTime(sectionTime: Double, totalTime: Int): Float {
9298
return (sectionTime / totalTime * 100).toInt().toFloat() / 100
9399
}
@@ -104,7 +110,7 @@ internal class GetRouteUseCaseImpl @Inject constructor(
104110
distance = leg.distance,
105111
end = with(leg.end) {
106112
Place(
107-
name = name,
113+
name = parsingName(name),
108114
coordinate = Coordinate(
109115
latitude = lat.toString(),
110116
longitude = lon.toString()
@@ -116,7 +122,7 @@ internal class GetRouteUseCaseImpl @Inject constructor(
116122
proportionOfSectionTime = calculateProportionOfSectionTime(leg.sectionTime, totalTime),
117123
start = with(leg.start) {
118124
Place(
119-
name = name,
125+
name = parsingName(name),
120126
coordinate = Coordinate(
121127
latitude = lat.toString(),
122128
longitude = lon.toString()

0 commit comments

Comments
 (0)