Skip to content

Commit

Permalink
[fix] #53 checklist 중 범위 type 일치율 계산 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
RyuKwanKon committed Jan 18, 2024
1 parent 834f0f8 commit 4538018
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
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
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 @@ -5,7 +5,7 @@

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());
Expand All @@ -17,7 +17,7 @@ public static int getAccuracy(PostCheckList postCheckList, CheckList checkList)
count += postCheckList.getSleepTalkingType().compareRateTo(checkList.getSleepTalkingType());
count += postCheckList.getSleepTurningType().compareRateTo(checkList.getSleepTurningType());
count += postCheckList.getSmokeType().compareRateTo(checkList.getSmokeType());
return (int) (count / 11) * 100;
return (int) (count * 100) / 11;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public class PostController {
private final PostService postService;

@GetMapping
public ResponseEntity<SuccessResponse<?>> getAllPosts(@UserId final Long userId,
public ResponseEntity<SuccessResponse<?>> getAllPosts(// @UserId final Long userId,
@RequestParam(required = false) final String key,
@RequestParam final String type,
@RequestParam(required = false) final String gender,
final Pageable pageable) {
final PostSearchResponseDto responseDto = postService.getAllPosts(userId, key, type, gender, pageable);
final PostSearchResponseDto responseDto = postService.getAllPosts(1L, key, type, gender, pageable);
return SuccessResponse.ok(responseDto);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public class SecurityConfig {
"api/member/reissue",
"api/department",
"/ws/*",
"/ws/**"
"/ws/**",
"/*",
"/**"
};

@Bean
Expand Down

0 comments on commit 4538018

Please sign in to comment.