Skip to content

Commit

Permalink
fix(article): bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gracefulBrown committed Jun 6, 2024
1 parent 397a54d commit bc5b656
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ private List<Article> fetchArticlesOf(Member member) {
}

// 가장 최근 아티클의 발행시간 조회
LocalDateTime latestArticlePublishedAt = existedArticles.stream()
.max(Comparator.comparing(Article::getPublishedAt)).get().getPublishedAt();
LocalDateTime latestArticlePublishedAt = findLatestPublishedAt(existedArticles);

// 최근 아티클 발행 시간 이후로 작성된 피드 추출
List<RssFeed> articlesAfter = rssFeeds.findArticlesAfter(latestArticlePublishedAt);
Expand All @@ -194,4 +193,11 @@ private List<Article> fetchArticlesOf(Member member) {
throw new RssFeedException("Failed to fetch RSS feed for member: " + member.getId(), e);
}
}

public LocalDateTime findLatestPublishedAt(List<Article> articles) {
return articles.stream()
.max(Comparator.comparing(Article::getPublishedAt))
.map(Article::getPublishedAt)
.orElseThrow(() -> new BadRequestException(ARTICLE_NOT_FOUND_EXCEPTION));
}
}

0 comments on commit bc5b656

Please sign in to comment.