Skip to content

Commit 6dc8341

Browse files
authored
Merge pull request #94 from SWYP-mingling/fix/SW-99-midpoint-score
Fix/sw 99 midpoint score
2 parents 15c23bb + ccee28f commit 6dc8341

File tree

5 files changed

+61
-6
lines changed

5 files changed

+61
-6
lines changed

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
FROM eclipse-temurin:21-jre-alpine AS builder
22
WORKDIR /app
33
COPY build/libs/*.jar app.jar
4+
5+
RUN mkdir /logs
6+
VOLUME /logs
7+
48
RUN java -Djarmode=layertools -jar app.jar extract
59

610
FROM eclipse-temurin:21-jre-alpine

src/main/java/swyp/mingling/domain/meeting/dto/response/midpoint/MidPointCandidate.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class MidPointCandidate {
1515
private int avgTime; // 평균 이동시간 or 총합
1616
private boolean isHot; // 가장 장소가 많은 곳
1717
private int placeCount; // 주변 장소 개수
18+
private double totalScore; // 편차, 이동시간 고려한 최종 점수
1819

1920
public void setHot(boolean hot) {
2021
isHot = hot;

src/main/java/swyp/mingling/domain/meeting/service/MidPointAsyncUseCase.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ public List<GetMidPointResponse> execute(UUID meetingId) {
170170

171171
int avgTime = sum / routes.size();
172172

173-
return new MidPointCandidate(routes, deviation, avgTime, false, placeCount);
173+
double totalScore = (avgTime * 0.6) + (deviation * 0.4);
174+
175+
return new MidPointCandidate(routes, deviation, avgTime, false, placeCount, totalScore);
174176
});
175177
})
176178
.toList();
@@ -193,8 +195,7 @@ public List<GetMidPointResponse> execute(UUID meetingId) {
193195
List<MidPointCandidate> sortedByFairness =
194196
candidates.stream()
195197
.sorted(
196-
Comparator.comparing(MidPointCandidate::getDeviation)
197-
.thenComparing(MidPointCandidate::getAvgTime)
198+
Comparator.comparing(MidPointCandidate::getTotalScore)
198199
)
199200
.limit(2)
200201
.toList();

src/main/java/swyp/mingling/domain/meeting/service/MidPointUseCase.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,17 @@ public List<GetMidPointResponse> execute(UUID meetingId) {
113113

114114
int avgTime = sum / routes.size();
115115

116+
double totalScore = (avgTime * 0.6) + (deviation * 0.4);
117+
116118
candidates.add(
117-
new MidPointCandidate(routes, deviation, avgTime, false, 0)
119+
new MidPointCandidate(routes, deviation, avgTime, false, 0, totalScore)
118120
);
119121
}
120122

121123
List<List<SubwayRouteInfo>> midlist =
122124
candidates.stream()
123125
.sorted(
124-
Comparator.comparing(MidPointCandidate::getDeviation)
125-
.thenComparing(MidPointCandidate::getAvgTime)
126+
Comparator.comparing(MidPointCandidate::getTotalScore)
126127
)
127128
.limit(3)
128129
.map(MidPointCandidate::getRoutes)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
4+
5+
<property name="LOG_PATH" value="/logs" />
6+
7+
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
8+
<encoder>
9+
<pattern>${CONSOLE_LOG_PATTERN}</pattern> </encoder>
10+
</appender>
11+
12+
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
13+
<file>${LOG_PATH}/warn.log</file>
14+
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
15+
<level>WARN</level> </filter>
16+
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
17+
<fileNamePattern>${LOG_PATH}/warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
18+
<maxFileSize>10MB</maxFileSize>
19+
<maxHistory>30</maxHistory>
20+
</rollingPolicy>
21+
<encoder>
22+
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
23+
</encoder>
24+
</appender>
25+
26+
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
27+
<file>${LOG_PATH}/error.log</file>
28+
<filter class="ch.qos.logback.classic.filter.LevelFilter">
29+
<level>ERROR</level>
30+
<onMatch>ACCEPT</onMatch>
31+
<onMismatch>DENY</onMismatch>
32+
</filter>
33+
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
34+
<fileNamePattern>${LOG_PATH}/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
35+
<maxFileSize>10MB</maxFileSize>
36+
<maxHistory>30</maxHistory>
37+
</rollingPolicy>
38+
<encoder>
39+
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
40+
</encoder>
41+
</appender>
42+
43+
<root level="INFO">
44+
<appender-ref ref="CONSOLE" />
45+
<appender-ref ref="WARN_FILE" />
46+
<appender-ref ref="ERROR_FILE" />
47+
</root>
48+
</configuration>

0 commit comments

Comments
 (0)