Skip to content

Commit

Permalink
fix(backend): return follower count correctly in tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mmtftr committed Dec 14, 2024
1 parent d543aa9 commit 2e044d7
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,16 @@ public GetTagDetailsResponseDto getTagDetails(Long tagId) {
following = false;
}

Long followerCount = (long) tagEntity.getFollowers().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);
responseDto.setFollowerCount(followerCount);
responseDto.setFollowing(following);
return responseDto;
} else if (tagType == TagType.PROGRAMMING_PARADIGM) {
Expand All @@ -117,6 +120,7 @@ public GetTagDetailsResponseDto getTagDetails(Long tagId) {
responseDto.setTagType(tagType.toString());
responseDto.setRelatedQuestions(relatedQuestions);
responseDto.setQuestionCount(questionCount);
responseDto.setFollowerCount(followerCount);
responseDto.setFollowing(following);
return responseDto;
}
Expand All @@ -128,6 +132,7 @@ public GetTagDetailsResponseDto getTagDetails(Long tagId) {
.tagType(getTagType(tagEntity).toString())
.relatedQuestions(relatedQuestions)
.questionCount(questionCount)
.followerCount(followerCount)
.following(following)
.build();

Expand All @@ -149,6 +154,7 @@ public Page<GetTagDetailsResponseDto> searchTags(String q, Pageable pageable) {
return tags.map(tag -> GetTagDetailsResponseDto.builder()
.tagId(tag.getId())
.questionCount((long) questionRepository.findQuestionsByTagId(tag.getId()).size())
.followerCount((long) tag.getFollowers().size())
.name(tag.getTagName())
.description(tag.getTagDescription())
.tagType(getTagType(tag).toString())
Expand Down

0 comments on commit 2e044d7

Please sign in to comment.