From 2e044d72727fd2b429c12dfe727e8af28999cc0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Efe=20Ak=C3=A7a?= Date: Sat, 14 Dec 2024 18:05:21 +0300 Subject: [PATCH] fix(backend): return follower count correctly in tags --- .../programminglanguagesforum/Services/TagService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/src/main/java/com/group1/programminglanguagesforum/Services/TagService.java b/backend/src/main/java/com/group1/programminglanguagesforum/Services/TagService.java index 3647c82..cfb4c18 100644 --- a/backend/src/main/java/com/group1/programminglanguagesforum/Services/TagService.java +++ b/backend/src/main/java/com/group1/programminglanguagesforum/Services/TagService.java @@ -101,6 +101,8 @@ 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, @@ -108,6 +110,7 @@ public GetTagDetailsResponseDto getTagDetails(Long tagId) { responseDto.setTagType(tagType.toString()); responseDto.setRelatedQuestions(relatedQuestions); responseDto.setQuestionCount(questionCount); + responseDto.setFollowerCount(followerCount); responseDto.setFollowing(following); return responseDto; } else if (tagType == TagType.PROGRAMMING_PARADIGM) { @@ -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; } @@ -128,6 +132,7 @@ public GetTagDetailsResponseDto getTagDetails(Long tagId) { .tagType(getTagType(tagEntity).toString()) .relatedQuestions(relatedQuestions) .questionCount(questionCount) + .followerCount(followerCount) .following(following) .build(); @@ -149,6 +154,7 @@ public Page 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())