Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 스터디 성공률 계산 로직 수정 #555

Open
wants to merge 2 commits into
base: BE/develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public double calculateSuccessRate(Member member) {
if (success + fail == 0) {
return 0;
}
return ((double) (success * 100) / success + fail);
return ((double) success / (success + fail)) * 100;
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.yigongil.backend.acceptance.steps;

import static io.restassured.RestAssured.given;
import static org.assertj.core.api.Assertions.as;
import static org.assertj.core.api.Assertions.assertThat;

import com.yigongil.backend.domain.study.ProcessingStatus;
import com.yigongil.backend.response.MyProfileResponse;
import com.yigongil.backend.response.MembersCertificationResponse;
import com.yigongil.backend.response.StudyDetailResponse;
import com.yigongil.backend.response.UpcomingRoundResponse;
Expand Down Expand Up @@ -115,4 +117,12 @@ public StudyProgressStep(SharedContext sharedContext) {

assertThat(studyDetailResponse.members()).allMatch(studyMemberResponse -> studyMemberResponse.tier() == expected);
}

@Then("{string}의 스터디 성공률이 {int} 퍼센트이다")
public void 성공률_계산(String memberGIthubId, int expected) {
MyProfileResponse myProfileResponse = sharedContext.getResponse()
.as(MyProfileResponse.class);

assertThat(myProfileResponse.successRate()).isEqualTo(expected);
}
}
32 changes: 32 additions & 0 deletions backend/src/test/resources/features/study-progress.feature
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,35 @@ Feature: 스터디를 진행한다
When "noiman" 이 "자바1" 스터디에서 탈퇴한다.

Then "noiman" 이 "자바1" 스터디에 참여하지 않는다.

Scenario: 스터디 하나 성공, 하나 실패하면 성공률이 50 퍼센트이다
Given "jinwoo"의 깃허브 아이디로 회원가입을 한다.
Given "jinwoo"가 제목-"자바1", 정원-"6"명, 최소 주차-"1"주, 주당 진행 횟수-"3"회, 소개-"스터디소개1"로 스터디를 개설한다.
Given "noiman"의 깃허브 아이디로 회원가입을 한다.
Given 깃허브 아이디가 "noiman"인 멤버가 이름이 "자바1"스터디에 신청한다.
Given "jinwoo"가 "noiman"의 "자바1" 스터디 신청을 수락한다.
Given "jinwoo"가 이름이 "자바1"인 스터디를 "MONDAY"에 진행되도록 하여 시작한다.

Given "jinwoo"가 이름이 "자바1"인 스터디의 현재 주차를 통해 현재 회차를 찾는다.
Given "jinwoo"가 찾은 회차에 "이번주 머두"로 머스트두를 추가한다.

When "jinwoo"가 "자바1"스터디 피드에 "내용"의 인증 글을 작성한다.
When "noiman"가 "자바1"스터디 피드에 "내용"의 인증 글을 작성한다.

Given 13일이 지난다.

When "jinwoo"가 "자바1" 스터디를 종료한다.

Given "jinwoo"가 제목-"자바2", 정원-"6"명, 최소 주차-"1"주, 주당 진행 횟수-"3"회, 소개-"스터디소개1"로 스터디를 개설한다.
Given 깃허브 아이디가 "noiman"인 멤버가 이름이 "자바2"스터디에 신청한다.
Given "jinwoo"가 "noiman"의 "자바2" 스터디 신청을 수락한다.
Given "jinwoo"가 이름이 "자바2"인 스터디를 "MONDAY"에 진행되도록 하여 시작한다.

Given "jinwoo"가 이름이 "자바2"인 스터디의 현재 주차를 통해 현재 회차를 찾는다.
Given "jinwoo"가 찾은 회차에 "이번주 머두"로 머스트두를 추가한다.
When "noiman" 이 "자바2" 스터디에서 탈퇴한다.
Given 13일이 지난다.
When "jinwoo"가 "자바2" 스터디를 종료한다.
When "noiman"가 마이페이지를 조회한다.

Then "noiman"의 스터디 성공률이 50 퍼센트이다
Loading