Skip to content
Snippets Groups Projects
Commit 54b06a4c authored by Otto Visser's avatar Otto Visser
Browse files

Merge branch...

Merge branch '468-queue-2-0-current-labs-view-seems-to-be-missing-from-home-page' into 'development'

Make current labs also show enqueueable labs

See merge request !489
parents 0d02cfeb 4b27c344
Branches
Tags
2 merge requests!598Dev to master,!489Make current labs also show enqueueable labs
......@@ -20,7 +20,6 @@ package nl.tudelft.queue.controller;
import static nl.tudelft.labracore.api.dto.PersonDetailsDTO.DefaultRoleEnum.ADMIN;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
......@@ -30,10 +29,7 @@ import nl.tudelft.labracore.api.EditionControllerApi;
import nl.tudelft.labracore.api.PersonControllerApi;
import nl.tudelft.labracore.api.RoleControllerApi;
import nl.tudelft.labracore.api.SessionControllerApi;
import nl.tudelft.labracore.api.dto.EditionDetailsDTO;
import nl.tudelft.labracore.api.dto.EditionSummaryDTO;
import nl.tudelft.labracore.api.dto.PersonDetailsDTO;
import nl.tudelft.labracore.api.dto.SessionDetailsDTO;
import nl.tudelft.labracore.api.dto.*;
import nl.tudelft.labracore.lib.security.user.AuthenticatedPerson;
import nl.tudelft.labracore.lib.security.user.Person;
import nl.tudelft.librador.dto.view.View;
......@@ -46,6 +42,7 @@ import nl.tudelft.queue.repository.FeedbackRepository;
import nl.tudelft.queue.repository.LabRepository;
import nl.tudelft.queue.service.EditionService;
import nl.tudelft.queue.service.FeedbackService;
import nl.tudelft.queue.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
......@@ -90,6 +87,9 @@ public class HomeController {
@Autowired
private EditionService es;
@Autowired
private PermissionService ps;
/**
* Sets a model attribute statically within every Thymeleaf resolution. This model attribute is to
* indicate the main tab that Home pages are in.
......@@ -139,12 +139,14 @@ public class HomeController {
var editions = eCache.get(roles.stream().map(r -> r.getEdition().getId()))
.stream().collect(Collectors.toMap(EditionDetailsDTO::getId, Function.identity()));
var sessions = roles.isEmpty() ? Collections.<SessionDetailsDTO>emptyList()
: sApi.getActiveSessionsInEditions(
roles.stream().map(r -> r.getEdition().getId()).collect(Collectors.toList()))
.collectList().block();
var labs = sessions.stream().collect(Collectors.toMap(SessionDetailsDTO::getId, s -> es.sortLabs(
View.convert(lr.findAllBySessions(List.of(s.getId())), QueueSessionSummaryDTO.class))));
var sessions = editions.values().stream()
.flatMap(e -> e.getSessions().stream())
.collect(Collectors.toList());
var labs = sessions.stream().collect(Collectors.toMap(SessionSummaryDTO::getId,
s -> es.sortLabs(View.convert(lr.findAllBySessions(List.of(s.getId())),
QueueSessionSummaryDTO.class)).stream()
.filter(qs -> ps.canEnqueueSelfNow(qs.getId()) || qs.getSlot().open())
.collect(Collectors.toList())));
if (pd.getDefaultRole() == ADMIN) {
var runningEditions = eCache.get(Objects.requireNonNull(
......
......@@ -33,7 +33,6 @@ import java.util.stream.Stream;
import nl.tudelft.labracore.api.EditionControllerApi;
import nl.tudelft.labracore.api.PersonControllerApi;
import nl.tudelft.labracore.api.RoleControllerApi;
import nl.tudelft.labracore.api.SessionControllerApi;
import nl.tudelft.labracore.api.dto.PersonDetailsDTO;
import nl.tudelft.labracore.api.dto.PersonSummaryDTO;
import nl.tudelft.queue.cache.EditionCacheManager;
......@@ -84,9 +83,6 @@ class HomeControllerTest {
@Autowired
private EditionControllerApi editionApi;
@Autowired
private SessionControllerApi sessionApi;
@MockBean
private FeedbackRepository feedbackRepository;
......@@ -126,7 +122,6 @@ class HomeControllerTest {
when(personApi.getPersonById(anyLong())).thenReturn(Mono.just(person));
when(roleApi.getPersonRolesInActiveEditions(anyLong())).thenReturn(Flux.empty());
when(editionCache.get(any(Stream.class))).thenReturn(List.of());
when(sessionApi.getActiveSessionsInEditions(anyList())).thenReturn(Flux.just());
mvc.perform(get("/"))
.andExpect(status().isOk())
......@@ -153,7 +148,6 @@ class HomeControllerTest {
when(editionCache.get(any(Stream.class))).thenReturn(List.of());
when(editionApi.getAllEditionsActiveAtDate(any(LocalDateTime.class)))
.thenReturn(Flux.empty());
when(sessionApi.getActiveSessionsInEditions(anyList())).thenReturn(Flux.just());
mvc.perform(get("/"))
.andExpect(status().isOk())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment