-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from Team-Going/develop
[release] v1.2.0 릴리즈
- Loading branch information
Showing
33 changed files
with
648 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
doorip-api/src/main/java/org/doorip/trip/actor/TripTendencyTestActor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package org.doorip.trip.actor; | ||
|
||
import org.doorip.trip.domain.Participant; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.IntStream; | ||
|
||
@Component | ||
public class TripTendencyTestActor { | ||
private static final String TRIP_PLAN = "여행 계획"; | ||
private static final String TRIP_PLACE = "여행 장소"; | ||
private static final String RESTAURANT = "식당"; | ||
private static final String PICTURE = "사진"; | ||
private static final String TRIP_SCHEDULE = "여행 일정"; | ||
private static final int INITIALIZATION = 0; | ||
private static final int HIGH_RANGE_STYLE = 3; | ||
private static final int HIGH_RANGE_STYLES = 5; | ||
private static final int CENTER_POS = 2; | ||
private final Map<Integer, String> prefer = Map.of( | ||
0, TRIP_PLAN, | ||
1, TRIP_PLACE, | ||
2, RESTAURANT, | ||
3, PICTURE, | ||
4, TRIP_SCHEDULE | ||
); | ||
|
||
public TripTendencyTestResult calculateTripTendencyTest(List<Participant> participants) { | ||
List<List<Integer>> rates = generateStyles(); | ||
List<List<Integer>> counts = generateStyles(); | ||
int participantCount = participants.size(); | ||
accumulateCounts(participants, counts); | ||
List<String> bestPrefer = calculateBestPrefer(counts, participantCount); | ||
calculateRatesAverage(rates, counts, participantCount); | ||
return TripTendencyTestResult.of(bestPrefer, rates, counts); | ||
} | ||
|
||
private List<List<Integer>> generateStyles() { | ||
List<List<Integer>> styles = new ArrayList<>(); | ||
IntStream.range(INITIALIZATION, HIGH_RANGE_STYLES) | ||
.forEach(i -> styles.add(i, new ArrayList<>(Arrays.asList(INITIALIZATION, INITIALIZATION, INITIALIZATION)))); | ||
return styles; | ||
} | ||
|
||
private void accumulateCounts(List<Participant> participants, List<List<Integer>> counts) { | ||
participants.forEach(participant -> { | ||
accumulateCount(counts, participant.getStyleA(), 0); | ||
accumulateCount(counts, participant.getStyleB(), 1); | ||
accumulateCount(counts, participant.getStyleC(), 2); | ||
accumulateCount(counts, participant.getStyleD(), 3); | ||
accumulateCount(counts, participant.getStyleE(), 4); | ||
}); | ||
} | ||
|
||
private List<String> calculateBestPrefer(List<List<Integer>> counts, int participantCount) { | ||
List<String> bestPrefer = new ArrayList<>(); | ||
IntStream.range(INITIALIZATION, HIGH_RANGE_STYLES) | ||
.forEach(i -> { | ||
List<Integer> count = counts.get(i); | ||
if (count.contains(participantCount)) { | ||
bestPrefer.add(prefer.get(i)); | ||
} | ||
}); | ||
return bestPrefer; | ||
} | ||
|
||
private void calculateRatesAverage(List<List<Integer>> rates, List<List<Integer>> counts, int participantCount) { | ||
double percentage = 100.0 / participantCount; | ||
IntStream.range(INITIALIZATION, HIGH_RANGE_STYLES) | ||
.forEach(i -> { | ||
List<Integer> rate = rates.get(i); | ||
List<Integer> count = counts.get(i); | ||
IntStream.range(INITIALIZATION, HIGH_RANGE_STYLE) | ||
.forEach(j -> rate.set(j, (int) Math.floor(count.get(j) * percentage))); | ||
}); | ||
} | ||
|
||
private void accumulateCount(List<List<Integer>> counts, int styleValue, int pos) { | ||
List<Integer> count = counts.get(pos); | ||
if (styleValue < CENTER_POS) { | ||
count.set(0, count.get(0) + 1); | ||
} else if (styleValue == CENTER_POS) { | ||
count.set(1, count.get(1) + 1); | ||
} else { | ||
count.set(2, count.get(2) + 1); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
doorip-api/src/main/java/org/doorip/trip/actor/TripTendencyTestResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.doorip.trip.actor; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
|
||
import java.util.List; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
public record TripTendencyTestResult( | ||
List<String> bestPrefer, | ||
List<List<Integer>> rates, | ||
List<List<Integer>> counts | ||
) { | ||
public static TripTendencyTestResult of(List<String> bestPrefer, List<List<Integer>> rates, List<List<Integer>> counts) { | ||
return TripTendencyTestResult.builder() | ||
.bestPrefer(bestPrefer) | ||
.rates(rates) | ||
.counts(counts) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
doorip-api/src/main/java/org/doorip/trip/dto/request/ParticipantUpdateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.doorip.trip.dto.request; | ||
|
||
public record ParticipantUpdateRequest( | ||
int styleA, | ||
int styleB, | ||
int styleC, | ||
int styleD, | ||
int styleE | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
doorip-api/src/main/java/org/doorip/trip/dto/request/TripUpdateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.doorip.trip.dto.request; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import java.time.LocalDate; | ||
|
||
public record TripUpdateRequest( | ||
String title, | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd", timezone = "Asia/Seoul") | ||
LocalDate startDate, | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd", timezone = "Asia/Seoul") | ||
LocalDate endDate | ||
) { | ||
} |
22 changes: 22 additions & 0 deletions
22
doorip-api/src/main/java/org/doorip/trip/dto/response/TodoDetailAllocatorResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.doorip.trip.dto.response; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import org.doorip.trip.domain.Participant; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
public record TodoDetailAllocatorResponse( | ||
Long participantId, | ||
String name, | ||
boolean isOwner, | ||
boolean isAllocated | ||
) { | ||
public static TodoDetailAllocatorResponse of(String name, boolean isOwner, boolean isAllocated, Participant participant) { | ||
return TodoDetailAllocatorResponse.builder() | ||
.participantId(participant.getId()) | ||
.name(name) | ||
.isOwner(isOwner) | ||
.isAllocated(isAllocated) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.