Skip to content

Commit

Permalink
More #302: fix bug where study duration by end date was calculated in…
Browse files Browse the repository at this point in the history
…correctly
  • Loading branch information
drtyyj committed Jun 4, 2024
1 parent 9d26cd8 commit 02f8fca
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import io.redlink.more.studymanager.repository.StudyGroupRepository;
import io.redlink.more.studymanager.repository.StudyRepository;
import io.redlink.more.studymanager.repository.UserRepository;

import java.time.temporal.ChronoUnit;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -205,11 +207,11 @@ public Optional<Duration> getStudyDuration(Long studyId) {
.flatMap(study ->
Optional.ofNullable(study.getDuration())
.or(() -> Optional.of(new Duration()
.setValue(
java.time.Period.between(
.setValue(Long.valueOf(
ChronoUnit.DAYS.between(
Objects.requireNonNullElse(study.getStartDate(), study.getPlannedStartDate()),
Objects.requireNonNullElse(study.getEndDate(), study.getPlannedEndDate())
).getDays() + 1)
) + 1).intValue())
.setUnit(Duration.Unit.DAY)
))
);
Expand Down

0 comments on commit 02f8fca

Please sign in to comment.