Skip to content

Commit

Permalink
refactor: 변수 네이밍 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
jjongwa committed Nov 20, 2023
1 parent ca1aed5 commit 45d1168
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private LikeElement getLikeElement(final Long memberId, final Long tripId) {
final Optional<LikeCount> likeCount = likeCountRepository.findById(tripId);
final Optional<MemberLike> memberLike = memberLikeRepository.findById(memberId);
if (likeCount.isPresent() && memberLike.isPresent()) {
final Map<Long, Boolean> tripLikeStatusMap = memberLike.get().getTripLikeStatusMap();
final Map<Long, Boolean> tripLikeStatusMap = memberLike.get().getLikeStatusForTrip();
if (tripLikeStatusMap.containsKey(tripId)) {
return new LikeElement(tripId, likeCount.get().getCount(), tripLikeStatusMap.get(tripId));
}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/java/hanglog/like/domain/MemberLike.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ public class MemberLike {
@Id
private Long memberId;

private Map<Long, Boolean> tripLikeStatusMap;
private Map<Long, Boolean> likeStatusForTrip;
}
4 changes: 2 additions & 2 deletions backend/src/main/java/hanglog/like/service/LikeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void update(final Long memberId, final Long tripId, final LikeRequest lik
Map<Long, Boolean> tripLikeStatusMap = new HashMap<>();
final Optional<MemberLike> memberLike = memberLikeRepository.findById(memberId);
if (memberLike.isPresent()) {
tripLikeStatusMap = memberLike.get().getTripLikeStatusMap();
tripLikeStatusMap = memberLike.get().getLikeStatusForTrip();
}
tripLikeStatusMap.put(tripId, likeRequest.getIsLike());
memberLikeRepository.save(new MemberLike(memberId, tripLikeStatusMap));
Expand All @@ -55,7 +55,7 @@ private void updateLikeCountCache(final Long tripId, final LikeRequest likeReque
public void writeBackMemberLikeCache() {
final List<Likes> likes = memberRepository.findAll().stream()
.flatMap(member -> memberLikeRepository.findById(member.getId())
.map(memberLike -> memberLike.getTripLikeStatusMap()
.map(memberLike -> memberLike.getLikeStatusForTrip()
.entrySet().stream()
.filter(Map.Entry::getValue)
.map(entry -> new Likes(entry.getKey(), member.getId())))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ void update() {
softly.assertThat(memberLikeRepository.findById(member.getId())).isPresent();
softly.assertThat(memberLikeRepository.findById(member.getId())
.get()
.getTripLikeStatusMap()
.getLikeStatusForTrip()
.get(tripId)).isTrue();

likeService.update(member.getId(), tripId, likeFalseRequest);
softly.assertThat(memberLikeRepository.findById(member.getId())).isPresent();
softly.assertThat(memberLikeRepository.findById(member.getId())
.get()
.getTripLikeStatusMap()
.getLikeStatusForTrip()
.get(tripId)).isFalse();
});
}
Expand Down

0 comments on commit 45d1168

Please sign in to comment.