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

[DELETE] PostView 관련 로직 다 삭제 #189

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading