Skip to content

Commit

Permalink
feat : evaluationScore
Browse files Browse the repository at this point in the history
  • Loading branch information
ecsimsw committed Aug 13, 2023
1 parent 213c65f commit d76f8fe
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
13 changes: 5 additions & 8 deletions src/main/java/se/ton/t210/domain/EvaluationScoreSection.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,21 @@ public class EvaluationScoreSection {
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
private Long id;

private Long evaluationItemId;

private int sectionBaseScore;

private int score;
private int evaluationScore;

public EvaluationScoreSection() {
}

public EvaluationScoreSection(Long id, Long evaluationItemId, int sectionBaseScore, int score) {
public EvaluationScoreSection(Long id, Long evaluationItemId, int sectionBaseScore, int evaluationScore) {
this.id = id;
this.evaluationItemId = evaluationItemId;
this.sectionBaseScore = sectionBaseScore;
this.score = score;
this.evaluationScore = evaluationScore;
}

public EvaluationScoreSection(Long evaluationItemId, int sectionBaseScore, int score) {
this(null, evaluationItemId, sectionBaseScore, score);
public EvaluationScoreSection(Long evaluationItemId, int sectionBaseScore, int evaluationScore) {
this(null, evaluationItemId, sectionBaseScore, evaluationScore);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public List<List<EvaluationSectionInfo>> sectionInfos(ApplicationType applicatio
evaluationItem.getName(),
prevItemBaseScore,
section.getSectionBaseScore(),
section.getScore()
section.getEvaluationScore()
);
evaluationSectionInfos.add(sectionInfo);
prevItemBaseScore = section.getSectionBaseScore() - 1;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/se/ton/t210/service/ScoreService.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ private void updateMonthlyScore(Member member, int evaluationScoreSum, LocalDate

public int evaluationScore(Long evaluationItemId, int score) {
return evaluationScoreSectionRepository.findAllByEvaluationItemId(evaluationItemId).stream()
.filter(it -> it.getSectionBaseScore() < score)
.max(Comparator.comparingInt(EvaluationScoreSection::getScore))
.map(EvaluationScoreSection::getScore)
.orElse(0);
.filter(it -> it.getSectionBaseScore() <= score)
.max(Comparator.comparingInt(EvaluationScoreSection::getEvaluationScore))
.map(EvaluationScoreSection::getEvaluationScore)
.orElseThrow(() -> new IllegalArgumentException("Invalid evaluationItemId or score"));
}

public List<RankResponse> rank(ApplicationType applicationType, int rankCnt, LocalDate date) {
Expand All @@ -87,10 +87,10 @@ public List<RankResponse> rank(ApplicationType applicationType, int rankCnt, Loc
int sameStack = 0;
for (var score : rankScores) {
final Member member = memberRepository.findById(score.getMemberId()).orElseThrow();
if(prevScore == score.getScore()) {
if (prevScore == score.getScore()) {
sameStack++;
} else {
rank = rank + sameStack +1;
rank = rank + sameStack + 1;
sameStack = 0;
}
prevScore = score.getScore();
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/se/ton/t210/utils/data/DummyData.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ public List<EvaluationItem> createDummyEvaluationItem(ApplicationType applicatio
new EvaluationScoreSection(item.getId(), 43, 3),
new EvaluationScoreSection(item.getId(), 46, 4),
new EvaluationScoreSection(item.getId(), 49, 5),
new EvaluationScoreSection(item.getId(), 52, 5),
new EvaluationScoreSection(item.getId(), 55, 5),
new EvaluationScoreSection(item.getId(), 61, 5),
new EvaluationScoreSection(item.getId(), 64, 5),
new EvaluationScoreSection(item.getId(), 68, 5)
new EvaluationScoreSection(item.getId(), 52, 6),
new EvaluationScoreSection(item.getId(), 55, 7),
new EvaluationScoreSection(item.getId(), 61, 8),
new EvaluationScoreSection(item.getId(), 64, 9),
new EvaluationScoreSection(item.getId(), 68, 10)
));
}
return evaluationItems;
Expand Down

0 comments on commit d76f8fe

Please sign in to comment.