Skip to content

Commit

Permalink
feat: #188 질문 총 개수 조회 로직 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
jaewonLeeKOR committed Sep 28, 2024
1 parent 0387ae0 commit 17f8a25
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
public class QuestionCountService {
private final QuestionRepository questionRepository;

@Cacheable(value = "boardCount", cacheManager = "noExpireCacheManager")
@Cacheable(value = "questionCount", cacheManager = "noExpireCacheManager")
public Integer getLiveOrOldQuestionCount() {
return questionRepository.getLiveOrOldQuestionCount();
}

@Async
@CachePut(value = "boardCount", cacheManager = "noExpireCacheManager")
@CachePut(value = "questionCount", cacheManager = "noExpireCacheManager")
public CompletableFuture<Integer> updateLiveOrOldQuestionCount() {
return CompletableFuture.completedFuture(questionRepository.getLiveOrOldQuestionCount());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class QuestionServiceImpl implements QuestionService {
private final AnswerRepository answerRepository;
private final QuestionMapper questionMapper;
private final QuestionHeartRedisRepository questionHeartRepository;
private final QuestionCountService questionCountService;

@Override
public Question findQuestion(Long questionId) {
Expand All @@ -49,7 +50,7 @@ public SliceResponse<QuestionInfo> getQuestions(Member member, Pageable pageable
Slice<QuestionInfoInterface> questionSlice = questionRepository.findAllByQuestionStatusIsLiveAndOldOrderByLivedAtDesc(member, pageable);
return SliceResponse.toSliceResponse(questionSlice, questionSlice.getContent().stream()
.map(questionInfoInterface -> questionMapper.toQuestionInfo(questionInfoInterface.getQuestion(), questionInfoInterface.getIsAnsweredByMember())
).toList(), null);
).toList(), questionCountService.getLiveOrOldQuestionCount());
}

@Override
Expand Down

0 comments on commit 17f8a25

Please sign in to comment.