Skip to content

Commit

Permalink
[DELETE] PostView 관련 로직 다 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
rookedsysc authored Aug 31, 2024
1 parent e84881f commit 1743873
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 74 deletions.
22 changes: 0 additions & 22 deletions src/main/java/com/gamemoonchul/application/PostViewService.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.gamemoonchul.application.post;

import com.gamemoonchul.application.CommentService;
import com.gamemoonchul.application.PostViewService;
import com.gamemoonchul.common.exception.BadRequestException;
import com.gamemoonchul.domain.entity.Post;
import com.gamemoonchul.domain.entity.redis.RedisPostDetail;
Expand All @@ -27,7 +26,6 @@
@RequiredArgsConstructor
public class PostOpenApiService {
private final PostRepository postRepository;
private final PostViewService postViewService;
private final CommentService commentService;
private final RedisPostDetailRepository redisPostDetailRepository;

Expand All @@ -38,7 +36,6 @@ public RedisPostDetail getPostDetails(Long postId, Long requestMemberId) {
if (optionalPostDetail.isEmpty()) {
Post post = postRepository.searchByPostId(postId).orElseThrow(() -> new BadRequestException(PostStatus.POST_NOT_FOUND));
post.viewCountUp();
postViewService.save(post);

redisPostDetail = redisPostDetailRepository.save(RedisPostDetail.toCache(post));
} else {
Expand Down
19 changes: 8 additions & 11 deletions src/main/java/com/gamemoonchul/domain/entity/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "post", indexes = {
@Index(name = "idx_vote_ratio_vote_count", columnList = "vote_ratio DESC, vote_count DESC"),
@Index(name = "idx_post_created_at_desc", columnList = "created_at DESC"),
@Index(name = "idx_view_count", columnList = "view_count DESC")
@Index(name = "idx_vote_ratio_vote_count", columnList = "vote_ratio DESC, vote_count DESC"),
@Index(name = "idx_post_created_at_desc", columnList = "created_at DESC"),
@Index(name = "idx_view_count", columnList = "view_count DESC")
})
public class Post extends BaseTimeEntity {
@Id
Expand All @@ -32,9 +32,6 @@ public class Post extends BaseTimeEntity {
@OneToMany(fetch = FetchType.LAZY, mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
private List<VoteOptions> voteOptions;

@OneToMany(fetch = FetchType.LAZY, mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
private List<PostView> postViews;

@OneToMany(fetch = FetchType.LAZY, mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Comment> comments;

Expand Down Expand Up @@ -88,15 +85,15 @@ public void addVoteOptions(List<VoteOptions> voteOptions) {

public Double getMinVoteRatio() {
int totalVoteCount = voteOptions.stream()
.mapToInt(voteOption -> voteOption.getVotes()
.size())
.sum();
.mapToInt(voteOption -> voteOption.getVotes()
.size())
.sum();
if (totalVoteCount == 0) {
return 0.0;
}
double firstIndexVoteRatio = (double) voteOptions.get(0)
.getVotes()
.size() / (double) totalVoteCount * 100;
.getVotes()
.size() / (double) totalVoteCount * 100;
return Math.min(100.0 - firstIndexVoteRatio, firstIndexVoteRatio);
}

Expand Down
27 changes: 0 additions & 27 deletions src/main/java/com/gamemoonchul/domain/entity/PostView.java

This file was deleted.

This file was deleted.

0 comments on commit 1743873

Please sign in to comment.