Skip to content

Commit

Permalink
Fix [#133] 태스크 생성 후 홈뷰 조회 플로우 에러 해결 (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
geniusYoo authored Jul 17, 2024
2 parents 2a604fb + 1430f94 commit bd2a01f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ public void create(Long categoryId, TaskCreateRequest taskCreateRequest) {
task.getId());

categoryTaskRepository.save(categoryTask);

taskTimerService.createTaskTimer(task.getId());
}

public void toggleTaskCompletionStatus(Long taskId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

@Slf4j
Expand All @@ -26,6 +27,7 @@ public class TaskTimerService {
public void createTaskTimer(Long taskId) {
taskTimerRepository.save(TaskTimer.create(3L, taskId));
}

public void calculateTaskTimerOnStop(Long taskId, StopTimerRequest stopTimerRequest) {
// userFacade.getUserByPrincipal().getId()
TaskTimer taskTimer = taskTimerRepository.findByUserIdAndTargetDateAndTaskId(3L, stopTimerRequest.targetDate(), taskId).orElseThrow(
Expand All @@ -41,9 +43,8 @@ public Map<Long, TaskTimer> getTaskTimerMapByTaskList(Long userId, LocalDate tar
}

public int getTaskTimeByTaskId(Long userId, LocalDate targetDate, Long taskId) {
TaskTimer taskTimer = taskTimerRepository.findByUserIdAndTargetDateAndTaskId(userId, targetDate, taskId).orElseThrow(
() -> new NotFoundException(ErrorMessage.NOT_FOUND)
);
return taskTimer.getTargetTime();
TaskTimer taskTimer = taskTimerRepository.findByUserIdAndTargetDateAndTaskId(userId, targetDate, taskId).orElse(null);
if (taskTimer == null) return 0;
else return taskTimer.getTargetTime();
}
}

0 comments on commit bd2a01f

Please sign in to comment.