mirror of
https://github.com/adityachandelgit/BookLore.git
synced 2026-01-05 21:00:39 -06:00
fix(ui): update tasks last run time to include timezone information (#2047)
* fix: update tasks last run time to include timezone information * fix: use system default timezone instead of assuming UTC
This commit is contained in:
@@ -7,7 +7,7 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@@ -27,8 +27,8 @@ public class TasksHistoryResponse {
|
||||
private TaskStatus status;
|
||||
private Integer progressPercentage;
|
||||
private String message;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
private LocalDateTime completedAt;
|
||||
private Instant createdAt;
|
||||
private Instant updatedAt;
|
||||
private Instant completedAt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -112,12 +114,16 @@ public class TaskHistoryService {
|
||||
.status(task.getStatus())
|
||||
.progressPercentage(task.getProgressPercentage())
|
||||
.message(task.getMessage())
|
||||
.createdAt(task.getCreatedAt())
|
||||
.updatedAt(task.getUpdatedAt())
|
||||
.completedAt(task.getCompletedAt())
|
||||
.createdAt(toUtcInstant(task.getCreatedAt()))
|
||||
.updatedAt(toUtcInstant(task.getUpdatedAt()))
|
||||
.completedAt(toUtcInstant(task.getCompletedAt()))
|
||||
.build();
|
||||
}
|
||||
|
||||
private Instant toUtcInstant(LocalDateTime localDateTime) {
|
||||
return localDateTime != null ? localDateTime.atZone(ZoneId.systemDefault()).toInstant() : null;
|
||||
}
|
||||
|
||||
private TasksHistoryResponse.TaskHistory createMetadataOnlyTaskInfo(TaskType taskType) {
|
||||
return TasksHistoryResponse.TaskHistory.builder()
|
||||
.id(null)
|
||||
|
||||
Reference in New Issue
Block a user