Skip to content

Commit

Permalink
feat: 챌린지 응답에 id 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ChoiWonYu committed Dec 2, 2023
1 parent 79d91b9 commit a521dd9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.togedong.participant.ParticipantStatus;

public record ChallengeResponse(String description, int participantCount, int progressPercent,
public record ChallengeResponse(String challengeId, String description, int participantCount, int progressPercent,
ParticipantStatus isParticipating
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
@Slf4j
public class DefaultMemberService implements MemberService {

private static final int NOT_PARTICIPANT_COUNT = 0;

private final MemberRepository userRepository;
private final ParticipantService participantService;
private final ChallengeService challengeService;
Expand Down Expand Up @@ -97,13 +99,15 @@ private ChallengeResponse includeMemberInfo(final Challenge challenge, final Mem
log.info("participant count : " + participantCount);

if (!participantService.alreadyParticipate(member, challenge)) {
return new ChallengeResponse(description, participantCount, 0,
return new ChallengeResponse(challenge.getId(), description, participantCount,
NOT_PARTICIPANT_COUNT,
NOT_PARTICIPANT);
}

int progressPercent = challenge.calculateProgressPercent(
member.calculateRecordsSum(challenge.getExercise()));
return new ChallengeResponse(description, participantCount, progressPercent, PARTICIPANT);
return new ChallengeResponse(challenge.getId(), description, participantCount,
progressPercent, PARTICIPANT);
}

private Member findMemberByName(final String name) {
Expand Down

0 comments on commit a521dd9

Please sign in to comment.