Skip to content
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
18 changes: 13 additions & 5 deletions .github/workflows/prod-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,19 @@ jobs:
- name: Create app-deploy folder에 move appspec.yml and scripts folder and zip app-deploy folder
run: |
mkdir app-deploy
cp scripts/*.sh appdeploy/
cp appspec.yml appdeploy/
cp appspec.yml app-deploy/
cd app-deploy
mkdir scripts
cd ..
cp scripts/*.sh app-deploy/scripts/
zip -r app-deploy.zip app-deploy


- name: Check files and folders
run: |
ls -al
ls -al scripts/
cat appspec.yml


# (8) appspec.yml, scripts 파일을 S3 버킷에 업로드
- name: Upload to AWS S3
Expand All @@ -124,5 +133,4 @@ jobs:
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \
--s3-location bucket=$S3_BUCKET_NAME,key=$GITHUB_SHA.zip,bundleType=zip

--s3-location bucket=$S3_BUCKET_NAME,key=deploy/$GITHUB_SHA.zip,bundleType=zip
2 changes: 1 addition & 1 deletion appspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 0.0
os: ubuntu

files:
- source: /
- source: ./
destination: /home/ubuntu/app
overwrite: yes

Expand Down
Empty file modified scripts/run.sh
100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion scripts/stop.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
sudo docker-compose down
sudo docker-compose down
sudo service codedeploy-agent start
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ public interface GroupRepository extends JpaRepository<Group, Long> {
* @param status
* @return
*/
List<Group> findAllByEndDateGreaterThanAndStatus(LocalDate now, Status status);
List<Group> findAllByEndDateLessThanAndStatus(LocalDate now, Status status);
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,21 @@ public interface JoinListRepository extends JpaRepository<JoinList, Long> {
@Query("SELECT j from JoinList j JOIN FETCH j.group g WHERE j.member = :member AND j.status = 'ACTIVE'")
List<JoinList> findAllActiveJoinGroupsByMember(@Param("member") Member member);

@Query("SELECT MAX(j.executedMissionCount) " +

@Query("SELECT CASE WHEN COUNT(DISTINCT j.executedMissionCount) = 1 " +
"THEN MAX(j.executedMissionCount) + 1 " +
"ELSE MAX(j.executedMissionCount) END " +
"FROM JoinList j " +
"WHERE j.group = :group " +
"AND j.status = :status ")
Integer findMaxExecutedMissionCountByGroupAndStatus(@Param("group") Group group, @Param("status") Status status);

@Query("SELECT COUNT(*) " +
@Query("SELECT COUNT(j) " +
"FROM JoinList j " +
"WHERE j.group = :group " +
"AND j.status = :status " +
"AND j.executedMissionCount = (SELECT MAX(j.executedMissionCount) " +
"FROM JoinList j " +
"WHERE j.group = :group " +
"AND j.status = :status )")
Integer findCurrentRoundPositionByGroupId(@Param("group") Group group, @Param("status") Status status);
"AND j.executedMissionCount = :currentFinishedRelayCount ")
Integer findCurrentRoundPositionByGroupId(@Param("group") Group group, @Param("status") Status status, @Param("currentFinishedRelayCount") Integer currentFinishedRelayCount);

/**
* 그룹에서 목표 릴레이 횟수를 달성한 회원의 수를 반환합니다.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class MissionSchedulerService {
*/
// todo : Transactionl을 붙여주는게 나을까..?
//@Scheduled(fixedRate = 5000) // 이전 Task 시작 시점으로부터 5초가 지난 후 Task 실행
@Async
//@Async
@Scheduled(cron = "1 * * * * *") // 1분마다 실행, cron 표현식
@Transactional
public void allocateMissionAtGroupStartTime() {
Expand All @@ -61,6 +61,7 @@ public void allocateMissionAtGroupStartTime() {
List<Exercise> exerciseList = exerciseRepository.findAll();

// 모든 그룹에 대해서 현재 시각이 그룹의 시작시간과 시간차이가 5초 이하인 그룹에 대해서 미션 할당 및 알림 보내기
System.out.println("not test : " + groupList.size());
LocalTime now = LocalTime.now();
for (Group group : groupList) {
long timeDiff = ChronoUnit.MINUTES.between(now, group.getStartTime()); // group.getStartTime - now
Expand Down Expand Up @@ -168,7 +169,7 @@ public void inActiveGroupsPastEndDate() {
log.info("============= 그룹 종료 일자 스케줄러 =============");
// 종료 여부에 관계없이 group이 Active한 그룹들 중에서 EndDate가 지난 그룹
LocalDate now = LocalDate.now();
List<Group> groupList = groupRepository.findAllByEndDateGreaterThanAndStatus(now, Status.ACTIVE);
List<Group> groupList = groupRepository.findAllByEndDateLessThanAndStatus(now, Status.ACTIVE);

for (Group group : groupList) {
// 그룹 inActive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public MissionResponse read(Long groupId, String email) {
Integer currentFinishedRelayCount = joinListRepository.findMaxExecutedMissionCountByGroupAndStatus(group, Status.ACTIVE);

// 현재 회차에서 몇 번째
Integer currentRoundPosition = joinListRepository.findCurrentRoundPositionByGroupId(group, Status.ACTIVE) + 1;
Integer currentRoundPosition = joinListRepository.findCurrentRoundPositionByGroupId(group, Status.ACTIVE, currentFinishedRelayCount) + 1;

return MissionResponse.toDto(mission, currentFinishedRelayCount, currentRoundPosition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ public static Group createGroup() {
.build();
}

public static Group createGroupWithStartTime(LocalTime startTime) {
LocalTime now = LocalTime.now().truncatedTo(ChronoUnit.SECONDS);
return Group.builder()
.name("name")
.emozi("emozi")
.color("red")
.description("desc")
.maxMemberNum(3)
.goalRelayNum(10)
.startTime(startTime)
.endTime(startTime.plusHours(1))
.existDays(5)
.penalty("커피 사기")
.code("code")
.checkIntervalTime(10)
.checkMaxNum(2)
.build();
}

public static Group createGroupWithName(String name) {
return Group.builder()
.name(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void findMaxExecutedMissionCountByGroupAndStatusTest() {

clear();

int cnt = joinListRepository.findCurrentRoundPositionByGroupId(group, Status.ACTIVE);
int cnt = joinListRepository.findCurrentRoundPositionByGroupId(group, Status.ACTIVE, 1);
assertThat(cnt).isEqualTo(2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void inActiveGroupPastEndDateTest() {
JoinList joinList = createJoinListForMember(member, group);
List<JoinList> joinLists = List.of(joinList);

given(groupRepository.findAllByEndDateGreaterThanAndStatus(any(), any())).willReturn(groupList);
given(groupRepository.findAllByEndDateLessThanAndStatus(any(), any())).willReturn(groupList);
given(joinListRepository.findByGroupAndStatus(any(Group.class), any())).willReturn(joinLists);

// when
Expand Down