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
Show file tree
Hide file tree
Changes from 2 commits
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 @@ -83,8 +84,8 @@ private List<JobDto> toJobDtos(List<Job> jobs, String timezoneId) {
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern(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))
.collect(Collectors.toList());
}

private JobDto toJobDto(Job job, String timezoneId, DateTimeFormatter dateFormatter, DateTimeFormatter timeFormatter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,9 @@ public List<Job> getJobs(JobType jobType) {
private List<Job> getJobs(Organization org, JobType jobType) {
try (Session session = openSession()) {
String queryString = "select j from Job j " +
"where j.org.id = :orgId " +
"and j.jobType = :jobType";
"where j.org.id = :orgId " +
"and j.jobType = :jobType " +
"order by j.id dsc";
Levi-Lehman marked this conversation as resolved.
Show resolved Hide resolved
Query<Job> query = session.createQuery(queryString);
query.setParameter("orgId", org.getId());
query.setParameter("jobType", jobType);
Expand Down