Skip to content

Commit

Permalink
fix : 전체게시물이 아닌 공개된 게시물만 가져오도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
donsonioc2010 committed Oct 18, 2023
1 parent 4c355d4 commit a985171
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public interface ArticleRepository extends JpaRepository<Article, Long> {

Page<Article> findAllByCreatedUserOrderByCreateAtDesc(User user, Pageable pageable);

Page<Article> findAllByBoardAndCreateAtBetweenOrderByLikeCountDesc(Board board, Timestamp startTimestamp, Timestamp endTimestamp, Pageable pageable);
Page<Article> findAllByBoardAndArticleStatusAndCreateAtBetweenOrderByLikeCountDesc(
Board board, ArticleStatus status, Timestamp startTimestamp, Timestamp endTimestamp, Pageable pageable
);

@Query(
value = "select a.id, u.nick_name as nickName, ac.title, ac.content, a.like_count as likeCount " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ public List<PopularArticleResponse> getPopularArticlesByBoardId(int page, int li

Board board = boardRepository.findById(boardId).orElseThrow(() -> BoardNotFoundException.EXCEPTION);

return articleRepository.findAllByBoardAndCreateAtBetweenOrderByLikeCountDesc(board ,sevenDaysAgoTimestamp, currentTimestamp, PageRequest.of(page, limit))
return articleRepository
.findAllByBoardAndArticleStatusAndCreateAtBetweenOrderByLikeCountDesc(board , PUBLIC, sevenDaysAgoTimestamp, currentTimestamp, PageRequest.of(page, limit))
.stream()
.map(article -> {
ArticleContent content = articleContentRepository.findByArticleAndLanguage(article, language).orElseThrow(() -> ArticleContentNotFoundException.EXCEPTION);
Expand Down

0 comments on commit a985171

Please sign in to comment.