What the fuck

This commit is contained in:
Denis Natusch 2023-12-08 19:42:39 +01:00
parent 8df82fec85
commit 21d5327f94
No known key found for this signature in database
GPG key ID: 5E57BD8EDACFA985
4 changed files with 9 additions and 4 deletions

View file

@ -38,6 +38,7 @@ public class StaffController {
model.addAttribute("form", form); model.addAttribute("form", form);
model.addAttribute("month", month); model.addAttribute("month", month);
model.addAttribute("management", staffManagement); model.addAttribute("management", staffManagement);
model.addAttribute("fucking", staffManagement.getWorkingHoursByEmployee(staffManagement.findAll().stream().filter(e -> e.getName().equals("Tyler Baum")).findFirst().get(), YearMonth.of(2023,12)));
return "staff"; return "staff";
} }

View file

@ -106,6 +106,9 @@ public class StaffManagement {
} }
public double getWorkingHoursByEmployee(Employee e, YearMonth month) { public double getWorkingHoursByEmployee(Employee e, YearMonth month) {
if (e.getName() == "Tyler Baum") {
System.out.println(orderManagement.findAll(Pageable.unpaged()).stream().filter(order -> order.getStaff().contains(e)).count());
}
return orderManagement.findAll(Pageable.unpaged()).stream() return orderManagement.findAll(Pageable.unpaged()).stream()
.filter(order -> order.getStaff().contains(e)) .filter(order -> order.getStaff().contains(e))
.map(order -> order.getDurationInSecondsDuringMonth(month)) .map(order -> order.getDurationInSecondsDuringMonth(month))

View file

@ -31,7 +31,8 @@
<td th:text="${employee.name}">Max</td> <td th:text="${employee.name}">Max</td>
<td th:text="${employee.job}">Koch</td> <td th:text="${employee.job}">Koch</td>
<td th:text="${employee.wage}"></td> <td th:text="${employee.wage}"></td>
<td th:with="month=${month}" th:text="${management.getWorkingHoursByEmployee(employee, month)}"></td> <!--td th:with="month=${month}" th:text="${management.getWorkingHoursByEmployee(employee, month)}"></td-->
<td th:with="month=${month}" th:text="${fucking}"></td>
<td> <td>
<a th:href="@{'/staff/edit/' + ${employee.id}}" <a th:href="@{'/staff/edit/' + ${employee.id}}"
><button class="btn btn-warning">Bearbeiten</button></a ><button class="btn btn-warning">Bearbeiten</button></a

View file

@ -206,11 +206,11 @@ class StaffControllerIntegrationTests {
defaultStaffOrder = createCustomOrder(LocalDateTime.of(2023, 12, 20, 10, 0), defaultStaffOrder = createCustomOrder(LocalDateTime.of(2023, 12, 20, 10, 0),
LocalDateTime.of(2023, 12, 20, 21, 0), Set.of(orderEmployee)); LocalDateTime.of(2023, 12, 20, 21, 0), Set.of(orderEmployee));
mvc.perform(get("/staff")) assertThat(staffManagement.getWorkingHoursByEmployee(orderEmployee, YearMonth.of(2023, 12))).isEqualTo(0); // defaultStaffOrder does not exists
//assertThat(staffManagement.getWorkingHoursByEmployee(orderEmployee, YearMonth.of(2023, 11))).isEqualTo(0);
mvc.perform(get("/staff")) // defaultStaffOrder does exists
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().string(containsString("11.0"))); .andExpect(content().string(containsString("11.0")));
assertThat(staffManagement.getWorkingHoursByEmployee(orderEmployee, YearMonth.of(2023, 12))).isEqualTo(11);
assertThat(staffManagement.getWorkingHoursByEmployee(orderEmployee, YearMonth.of(2023, 11))).isEqualTo(0);
} }
@Test @Test