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] 정렬기준 default 값 변경 #54

Merged
merged 11 commits into from
Jan 19, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.gachon.checkmate.domain.checkList.converter;

import jakarta.persistence.Converter;
import org.gachon.checkmate.domain.checkList.entity.CallType;
import org.gachon.checkmate.global.utils.AbstractEnumCodeAttributeConverter;

@Converter
public class CallTypeConverter extends AbstractEnumCodeAttributeConverter<CallType> {
public CallTypeConverter() {
super(CallType.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.gachon.checkmate.domain.checkList.converter;

import jakarta.persistence.Converter;
import org.gachon.checkmate.domain.checkList.entity.EarPhoneType;
import org.gachon.checkmate.global.utils.AbstractEnumCodeAttributeConverter;

@Converter
public class EarPhoneTypeConverter extends AbstractEnumCodeAttributeConverter<EarPhoneType> {
public EarPhoneTypeConverter() {
super(EarPhoneType.class);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ public record CheckListRequestDto(
DrinkType drinkType,
HomeType homeType,
LifePatternType lifePatternType,
NoiseType noiseType,
CallType callType,
EarPhoneType earPhoneType,
SleepGridingType sleepGridingType,
SleepSnoreType sleepSnoreType,
SleepTalkingType sleepTalkingType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public record CheckListResponseDto(
String drinkType,
String homeType,
String lifePatterType,
String noiseType,
String callType,
String earPhoneType,
String sleepGridingType,
String sleepSnoreType,
String sleepTalkingType,
Expand All @@ -22,7 +23,8 @@ public static CheckListResponseDto of(CheckList checkList) {
.drinkType(checkList.getDrinkType().getDesc())
.homeType(checkList.getHomeType().getDesc())
.lifePatterType(checkList.getLifePatternType().getDesc())
.noiseType(checkList.getNoiseType().getDesc())
.callType(checkList.getCallType().getCode())
.earPhoneType(checkList.getEarPhoneType().getCode())
.sleepGridingType(checkList.getSleepGridingType().getDesc())
.sleepSnoreType(checkList.getSleepSnoreType().getDesc())
.sleepTalkingType(checkList.getSleepTalkingType().getDesc())
Expand All @@ -37,7 +39,8 @@ public static CheckListResponseDto ofPostCheckList(PostCheckList checkList) {
.drinkType(checkList.getDrinkType().getDesc())
.homeType(checkList.getHomeType().getDesc())
.lifePatterType(checkList.getLifePatternType().getDesc())
.noiseType(checkList.getNoiseType().getDesc())
.callType(checkList.getCallType().getCode())
.earPhoneType(checkList.getEarPhoneType().getCode())
.sleepGridingType(checkList.getSleepGridingType().getDesc())
.sleepSnoreType(checkList.getSleepSnoreType().getDesc())
.sleepTalkingType(checkList.getSleepTalkingType().getDesc())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@

@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
public enum NoiseType implements EnumField {
EARPHONE("1", "이어폰 필수"),
OUTSIDE("2", "전화는 밖에서"),
SHORT("3", "전화는 짧게"),
ANYWAY("4", "상관없음");
public enum CallType implements EnumField {
OUTSIDE("1", "밖에서"),
INSIDE("2", "안에서"),
ANYWAY("3", "상관없음");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기획적인 의견이긴한데..

  1. 밖에서
  2. 5분 이내는 안에서
  3. 상관없음
    로 나누는건 어떤가요? 현재는 2번과 3번이 둘이 비슷해보여서 의견드립니당

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

음 뭔가 딱 와 닿는게 없어서 회의 때 말 해볼까요?? 저도 뭔가 딱 기준이 안세워지네요


private final String code;
private final String desc;

public int compareRateTo(NoiseType e) {
public int compareRateTo(CallType e) {
return this.equals(e) ? 1 : 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ public class CheckList extends BaseTimeEntity {
private HomeType homeType;
@Convert(converter = LifePatternTypeConverter.class)
private LifePatternType lifePatternType;
@Convert(converter = NoiseTypeConverter.class)
private NoiseType noiseType;
@Convert(converter = CallTypeConverter.class)
private CallType callType;
@Convert(converter = EarPhoneTypeConverter.class)
private EarPhoneType earPhoneType;
@Convert(converter = SleepGridingTypeConverter.class)
private SleepGridingType sleepGridingType;
@Convert(converter = SleepSnoreTypeConverter.class)
Expand All @@ -47,7 +49,8 @@ public static CheckList createCheckList(User user, CheckListRequestDto checkList
.drinkType(checkListRequestDto.drinkType())
.homeType(checkListRequestDto.homeType())
.lifePatternType(checkListRequestDto.lifePatternType())
.noiseType(checkListRequestDto.noiseType())
.callType(checkListRequestDto.callType())
.earPhoneType(checkListRequestDto.earPhoneType())
.sleepGridingType(checkListRequestDto.sleepGridingType())
.sleepSnoreType(checkListRequestDto.sleepSnoreType())
.sleepTalkingType(checkListRequestDto.sleepTalkingType())
Expand All @@ -64,7 +67,8 @@ public void updateCheckList(CheckListRequestDto checkListRequestDto) {
this.drinkType = checkListRequestDto.drinkType();
this.homeType = checkListRequestDto.homeType();
this.lifePatternType = checkListRequestDto.lifePatternType();
this.noiseType = checkListRequestDto.noiseType();
this.callType = checkListRequestDto.callType();
this.earPhoneType = checkListRequestDto.earPhoneType();
this.sleepGridingType = checkListRequestDto.sleepGridingType();
this.sleepSnoreType = checkListRequestDto.sleepSnoreType();
this.sleepTalkingType = checkListRequestDto.sleepTalkingType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public enum CleanType implements EnumField {
private final String desc;
private final int size = 5;

public int compareRateTo(CleanType e) {
return 1 - Math.abs(Integer.parseInt(this.getCode()) - Integer.parseInt(e.getCode())) / (this.size - 1);
public double compareRateTo(CleanType e) {
return 1 - (double) Math.abs(Integer.parseInt(this.getCode()) - Integer.parseInt(e.getCode())) / (this.size - 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public enum DrinkType implements EnumField {
private final String desc;
private final int size = 4;

public int compareRateTo(DrinkType e) {
return 1 - Math.abs(Integer.parseInt(this.getCode()) - Integer.parseInt(e.getCode())) / (this.size - 1);
public double compareRateTo(DrinkType e) {
return 1 - (double) Math.abs(Integer.parseInt(this.getCode()) - Integer.parseInt(e.getCode())) / (this.size - 1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.gachon.checkmate.domain.checkList.entity;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.gachon.checkmate.global.utils.EnumField;

@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
public enum EarPhoneType implements EnumField {
NEED("1", "이어폰 필수"),
NOT_NEED("2", "상관없음");

private final String code;
private final String desc;

public int compareRateTo(EarPhoneType e) {
return this.equals(e) ? 1 : 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public enum HomeType implements EnumField {
private final String desc;
private final int size = 4;

public int compareRateTo(HomeType e) {
return 1 - Math.abs(Integer.parseInt(this.getCode()) - Integer.parseInt(e.getCode())) / (this.size - 1);
public double compareRateTo(HomeType e) {
return 1 - (double) Math.abs(Integer.parseInt(this.getCode()) - Integer.parseInt(e.getCode())) / (this.size - 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ public class PostCheckList extends BaseTimeEntity {
private HomeType homeType;
@Convert(converter = LifePatternTypeConverter.class)
private LifePatternType lifePatternType;
@Convert(converter = NoiseTypeConverter.class)
private NoiseType noiseType;
@Convert(converter = CallTypeConverter.class)
private CallType callType;
@Convert(converter = EarPhoneTypeConverter.class)
private EarPhoneType earPhoneType;
@Convert(converter = SleepGridingTypeConverter.class)
private SleepGridingType sleepGridingType;
@Convert(converter = SleepSnoreTypeConverter.class)
Expand All @@ -47,7 +49,8 @@ public static PostCheckList createPostCheckList(CheckListRequestDto checkListReq
.drinkType(checkListRequestDto.drinkType())
.homeType(checkListRequestDto.homeType())
.lifePatternType(checkListRequestDto.lifePatternType())
.noiseType(checkListRequestDto.noiseType())
.callType(checkListRequestDto.callType())
.earPhoneType(checkListRequestDto.earPhoneType())
.sleepGridingType(checkListRequestDto.sleepGridingType())
.sleepSnoreType(checkListRequestDto.sleepSnoreType())
.sleepTalkingType(checkListRequestDto.sleepTalkingType())
Expand All @@ -64,7 +67,8 @@ public void updatePostCheckList(CheckListRequestDto checkListRequestDto) {
this.drinkType = checkListRequestDto.drinkType();
this.homeType = checkListRequestDto.homeType();
this.lifePatternType = checkListRequestDto.lifePatternType();
this.noiseType = checkListRequestDto.noiseType();
this.callType = checkListRequestDto.callType();
this.earPhoneType = checkListRequestDto.earPhoneType();
this.sleepGridingType = checkListRequestDto.sleepGridingType();
this.sleepSnoreType = checkListRequestDto.sleepSnoreType();
this.sleepTalkingType = checkListRequestDto.sleepTalkingType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@

public class MatchRateCalculator {
public static int getAccuracy(PostCheckList postCheckList, CheckList checkList) {
int count = 0;
double count = 0;
count += postCheckList.getCleanType().compareRateTo(checkList.getCleanType());
count += postCheckList.getDrinkType().compareRateTo(checkList.getDrinkType());
count += postCheckList.getHomeType().compareRateTo(checkList.getHomeType());
count += postCheckList.getLifePatternType().compareRateTo(checkList.getLifePatternType());
count += postCheckList.getNoiseType().compareRateTo(checkList.getNoiseType());
count += postCheckList.getCallType().compareRateTo(checkList.getCallType());
count += postCheckList.getEarPhoneType().compareRateTo(checkList.getEarPhoneType());
count += postCheckList.getSleepGridingType().compareRateTo(checkList.getSleepGridingType());
count += postCheckList.getSleepSnoreType().compareRateTo(checkList.getSleepSnoreType());
count += postCheckList.getSleepTalkingType().compareRateTo(checkList.getSleepTalkingType());
count += postCheckList.getSleepTurningType().compareRateTo(checkList.getSleepTurningType());
count += postCheckList.getSmokeType().compareRateTo(checkList.getSmokeType());
return (int) (count / 10) * 100;
return (int) (count * 100) / 11;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
public enum PostSortType implements EnumField {
ACCURACY("1", "accuracy"),
REGISTER("2", "register"),
REGISTER("1", "register"),
ACCURACY("2", "accuracy"),
REMAIN_DATE("3", "remain date"),
SCRAP("4", "scrap");

Expand Down