in technology/kubernetes/demo-app/src/main/java/org/acme/demoapp/generator/DemoDataGenerator.java [66:88]
List<Timeslot> generateTimeslots(long problemId, int count) {
int sanitizedCount = count > 30 ? 30 : count; // Maximum of 30 timeslots per week.
LocalTime startTime = LocalTime.of(8, 0);
DayOfWeek startDay = DayOfWeek.MONDAY;
DayOfWeek currentDay = startDay;
LocalTime currentStartTime = startTime;
List<Timeslot> timeslots = new ArrayList<>(sanitizedCount);
for (int i = 0; i < sanitizedCount; i++) {
Timeslot timeslot = new Timeslot(problemId, currentDay, currentStartTime, currentStartTime.plusHours(1));
timeslots.add(timeslot);
if (currentStartTime.getHour() == 10) { // Lunch break.
currentStartTime = currentStartTime.plusHours(3);
} else if (currentStartTime.getHour() == 15) { // The next day.
currentStartTime = startTime;
currentDay = currentDay.plus(1);
} else {
currentStartTime = currentStartTime.plusHours(1);
}
}
return timeslots;
}