Skip to content

Commit

Permalink
Bugfix for questionCount.
Browse files Browse the repository at this point in the history
  • Loading branch information
EnesBaserr committed Dec 4, 2024
1 parent 7f7d43e commit f721597
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,23 @@ public GetTagDetailsResponseDto getTagDetails(Long tagId) {
List<GetQuestionWithTagDto> relatedQuestions = questions.stream()
.map(question -> modelMapper.map(question, GetQuestionWithTagDto.class))
.toList();
Long questionCount = (long) questions.size();

if (tagType == TagType.PROGRAMMING_LANGUAGE) {
ProgrammingLanguagesTag languageTag = (ProgrammingLanguagesTag) tagEntity;
GetProgrammingLanguageTagResponseDto responseDto = modelMapper.map(languageTag,
GetProgrammingLanguageTagResponseDto.class);
responseDto.setTagType(tagType.toString());
responseDto.setRelatedQuestions(relatedQuestions);
responseDto.setQuestionCount(questionCount);
return responseDto;
} else if (tagType == TagType.PROGRAMMING_PARADIGM) {
ProgrammingParadigmTag paradigmTag = (ProgrammingParadigmTag) tagEntity;
GetProgrammingParadigmResponseDto responseDto = modelMapper.map(paradigmTag,
GetProgrammingParadigmResponseDto.class);
responseDto.setTagType(tagType.toString());
responseDto.setRelatedQuestions(relatedQuestions);
responseDto.setQuestionCount(questionCount);
return responseDto;
}

Expand All @@ -93,6 +96,7 @@ public GetTagDetailsResponseDto getTagDetails(Long tagId) {
.description(tagEntity.getTagDescription())
.tagType(getTagType(tagEntity).toString())
.relatedQuestions(relatedQuestions)
.questionCount(questionCount)

.build();

Expand All @@ -102,6 +106,7 @@ public Page<GetTagDetailsResponseDto> searchTags(String q, Pageable pageable) {
Page<Tag> tags = tagRepository.findTagsByTagNameContainingIgnoreCase(q, pageable);
return tags.map(tag -> GetTagDetailsResponseDto.builder()
.tagId(tag.getId())
.questionCount((long) questionRepository.findQuestionsByTagId(tag.getId()).size())
.name(tag.getTagName())
.description(tag.getTagDescription())
.tagType(getTagType(tag).toString())
Expand Down

0 comments on commit f721597

Please sign in to comment.