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

[BE] 페어룸 완료 시 타이머 종료 #1155

Merged
merged 1 commit into from
Feb 19, 2025
Merged
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 @@ -106,6 +106,10 @@ public boolean isActive() {
return status != PairRoomStatus.COMPLETED && status != PairRoomStatus.DELETED;
}

public boolean isCompleted() {
return status == PairRoomStatus.COMPLETED;
}

public boolean isDeleted() {
return status == PairRoomStatus.DELETED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import site.coduo.pairroom.repository.PairRoomEntity;
import site.coduo.pairroom.repository.PairRoomRepository;
import site.coduo.timer.domain.Timer;
import site.coduo.timer.domain.TimerStatus;
import site.coduo.timer.repository.TimerEntity;
Expand All @@ -30,6 +32,7 @@ public class SchedulerService {
private final SchedulerRegistry schedulerRegistry;
private final TimestampRegistry timestampRegistry;
private final TimerRepository timerRepository;
private final PairRoomRepository pairRoomRepository;

public void start(final String key) {
if (schedulerRegistry.isActive(key)) {
Expand Down Expand Up @@ -62,7 +65,8 @@ private void runTimer(final String key, final Timer timer) {
reset(key, timer);
return;
}
if (timerStompManager.isTimerIdle(key) && schedulerRegistry.isActive(key)) {
PairRoomEntity pairRoomEntity = pairRoomRepository.fetchByAccessCode(key);
if (timerStompManager.isTimerIdle(key) && schedulerRegistry.isActive(key) || pairRoomEntity.isCompleted()) {
schedulerRegistry.release(key);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import site.coduo.pairroom.domain.accesscode.AccessCode;
import site.coduo.pairroom.repository.PairRoomEntity;
import site.coduo.pairroom.repository.PairRoomRepository;
import site.coduo.timer.domain.Timer;
import site.coduo.timer.repository.TimerEntity;
import site.coduo.timer.repository.TimerRepository;
Expand All @@ -25,6 +26,7 @@
@SpringBootTest
class SchedulerServiceTest {

@Autowired
private ThreadPoolTaskScheduler taskScheduler;

@Autowired
Expand All @@ -33,8 +35,15 @@ class SchedulerServiceTest {
@Autowired
private TimestampRegistry timestampRegistry;

@Autowired
private PairRoomRepository pairRoomRepository;

@Autowired
private TimerStompManager timerStompManager;

@Autowired
private TimerRepository timerRepository;

private SchedulerService schedulerService;

@BeforeEach
Expand All @@ -46,7 +55,8 @@ void setUp() {
taskScheduler,
schedulerRegistry,
timestampRegistry,
timerRepository
timerRepository,
pairRoomRepository
);
}

Expand Down
Loading