Skip to content

Commit

Permalink
Merge pull request #685 from bounswe/627-backend-get-usersuserid-shou…
Browse files Browse the repository at this point in the history
…ld-return-answer-questions-for-that-user

627 [BACKEND] GET users/{userid} should return answers, questions, and followed tags for that user
  • Loading branch information
Cgtycolak authored Dec 16, 2024
2 parents 4cae533 + be4aff2 commit d20138e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,14 @@ public ResponseEntity<GenericApiResponse<SelfProfileResponseDto>> getUser() {
List<QuestionSummaryDto> questions = questionService.findByAuthorId(user.getId());
List<GetAnswerDtoForProfile> answers = answerService.findByAnsweredBy(user.getId());
selfProfileResponseDto.setFollowedTags(
tagService.getFollowedTags(user.getId())
);
tagService.getFollowedTags(user.getId()));
selfProfileResponseDto.setReputationPoints(userService.calculateReputation(user));
selfProfileResponseDto.setQuestionCount((long) questions.size());
selfProfileResponseDto.setQuestions(
questions);
questions);
selfProfileResponseDto.setAnswerCount((long) answers.size());
selfProfileResponseDto.setAnswers(
answers);

answers);

GenericApiResponse<SelfProfileResponseDto> response = ApiResponseBuilder.buildSuccessResponse(
selfProfileResponseDto.getClass(),
Expand Down Expand Up @@ -84,10 +82,13 @@ public ResponseEntity<GenericApiResponse<UserProfileResponseDto>> getUserById(
UserProfileResponseDto.class);
userProfileResponseDto.setReputationPoints(userService.calculateReputation(user.get()));
userProfileResponseDto.setSelfFollowing(userService.selfFollowing(user.get()));
userProfileResponseDto.setFollowedTags(
tagService.getFollowedTags(user.get().getId())
);

List<QuestionSummaryDto> questions = questionService.findByAuthorId(id);
userProfileResponseDto.setQuestions(questions);
userProfileResponseDto.setQuestionCount((long) questions.size());
List<GetAnswerDtoForProfile> answers = answerService.findByAnsweredBy(id);
userProfileResponseDto.setAnswers(answers);
userProfileResponseDto.setAnswerCount((long) answers.size());
userProfileResponseDto.setFollowedTags(tagService.getFollowedTags(id));

GenericApiResponse<UserProfileResponseDto> response = ApiResponseBuilder.buildSuccessResponse(
userProfileResponseDto.getClass(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.group1.programminglanguagesforum.DTOs.Responses;

import com.group1.programminglanguagesforum.Entities.ExperienceLevel;
import lombok.*;

Expand All @@ -25,5 +26,7 @@ public class UserProfileResponseDto {
private ExperienceLevel experienceLevel;
@Builder.Default
private List<SelfProfileResponseDto.FollowedTags> followedTags = new ArrayList<>();

private Long questionCount;
private List<QuestionSummaryDto> questions;
private List<GetAnswerDtoForProfile> answers;
}

0 comments on commit d20138e

Please sign in to comment.