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

Sorting jobs by date/time #139

Merged
merged 6 commits into from
Jun 22, 2023
Merged
Changes from 1 commit
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 @@ -26,6 +26,7 @@
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -82,11 +83,15 @@ private List<JobDto> toJobDtos(List<Job> jobs, String timezoneId) {
String zoneId = !Strings.isNullOrEmpty(timezoneId) ? timezoneId : "EST";
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern(TIME_FORMAT);
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DATE_FORMAT + " " + TIME_FORMAT);
return jobs.stream()
Levi-Lehman marked this conversation as resolved.
Show resolved Hide resolved
.map(job -> toJobDto(job, zoneId, dateFormatter, timeFormatter))
.collect(Collectors.toList());
.map(job -> toJobDto(job, zoneId, dateFormatter, timeFormatter))
.sorted(Comparator.comparing((JobDto jobDto) -> LocalDateTime.parse(jobDto.date + " " + jobDto.time, dateTimeFormatter))
.reversed())
.collect(Collectors.toList());
}


private JobDto toJobDto(Job job, String timezoneId, DateTimeFormatter dateFormatter, DateTimeFormatter timeFormatter) {
JobDto jobDto = new JobDto();
jobDto.traceId = job.traceId;
Expand Down