Skip to content
Snippets Groups Projects
Commit b0b5d060 authored by Cédric Willekens's avatar Cédric Willekens
Browse files

Make sure that claimed time slots are sorted

parent 282a454d
Branches
No related tags found
1 merge request!254Resolve "Claimed slots in admin view not sorted correctly"
......@@ -21,6 +21,7 @@ package nl.tudelft.ewi.walkytalky.controller;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
......@@ -210,6 +211,7 @@ public class UnitController {
Unit unit = unitRepository.findById(id).orElseThrow();
List<ClaimedTimeSlot> claimedTimeSlots = claimedTimeSlotRepository
.findAllByUnitOnOrAfterDate(unit, LocalDate.now());
Collections.sort(claimedTimeSlots);
model.addAttribute("slots", claimedTimeSlots);
model.addAttribute("unit", unit);
......
......@@ -39,7 +39,7 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class ClaimedTimeSlot {
public class ClaimedTimeSlot implements Comparable<ClaimedTimeSlot>{
@Id
@GeneratedValue
private Long id;
......@@ -87,4 +87,9 @@ public class ClaimedTimeSlot {
public int hashCode() {
return Objects.hash(getId());
}
@Override
public int compareTo(ClaimedTimeSlot claimedTimeSlot) {
return this.slot.start().compareTo(claimedTimeSlot.getSlot().start());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment