Skip to content

Commit

Permalink
add timeClock logging
Browse files Browse the repository at this point in the history
  • Loading branch information
bseber authored and derTobsch committed Jul 19, 2024
1 parent 4f602bd commit c629554
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public TimeClock updateTimeClock(UserId userId, TimeClockUpdate timeClockUpdate)

final TimeClockEntity timeClockEntity = toEntity(timeClock);

LOG.info("Updating TimeClock for user {}", userId.value());
LOG.debug("Next TimeClock: {}", timeClock);

return toTimeClock(timeClockRepository.save(timeClockEntity));
}

Expand All @@ -121,14 +124,16 @@ void stopTimeClock(UserId userId) {
.map(entity -> timeClockEntityWithStoppedAt(entity, ZonedDateTime.now(userSettingsProvider.zoneId())))
.map(timeClockRepository::save)
.map(TimeClockService::toTimeClock)
.ifPresent(timeClock -> {

final ZonedDateTime start = timeClock.startedAt();
final ZonedDateTime end = timeClock.stoppedAt()
.orElseThrow(() -> new IllegalStateException("expected stoppedAt to contain a value."));

timeEntryService.createTimeEntry(userId, timeClock.comment(), start, end, timeClock.isBreak());
});
.ifPresentOrElse(
timeClock -> {
final ZonedDateTime start = timeClock.startedAt();
final ZonedDateTime end = timeClock.stoppedAt()
.orElseThrow(() -> new IllegalStateException("expected stoppedAt to contain a value."));

LOG.info("Stopping TimeClock={} for user={} and creating TimeEntry for it.", timeClock.id(), userId.value());
timeEntryService.createTimeEntry(userId, timeClock.comment(), start, end, timeClock.isBreak());
},
() -> LOG.info("Not stopping TimeClock for user {} since nothing found. No TimeEntry created.", userId.value()));
}

private static TimeClockEntity toEntity(TimeClock timeClock) {
Expand Down

0 comments on commit c629554

Please sign in to comment.