Skip to content
Snippets Groups Projects

Resolve "Loading time old lab"

5 files
+ 54
37
Compare changes
  • Side-by-side
  • Inline

Files

@@ -86,6 +86,9 @@ public class EditionController {
@Autowired
private EditionCacheManager eCache;
@Autowired
private EditionRolesCacheManager erCache;
@Autowired
private ModuleCacheManager mCache;
@@ -137,7 +140,9 @@ public class EditionController {
var editions = eApi
.getEditionsPageActiveOrTaughtBy(person.getId(), fromPageable(pageable))
.block();
eCache.register(editions.getContent());
erCache.get(editions.getContent().stream().map(EditionDetailsDTO::getId));
model.addAttribute("editions",
new PageImpl<>(editions.getContent(), pageable, editions.getTotalElements()));
@@ -277,13 +282,16 @@ public class EditionController {
Model model) {
var edition = eCache.getOrThrow(editionId);
// Make sure that session details are cached and then convert to summaries.
// Make sure that session details are cached.
var sessions = sCache.get(edition.getSessions().stream()
.map(SessionSummaryDTO::getId));
var labs = es.filterLabs(getLabSummariesFromSessions(sessions, s -> true), queueSessionTypes,
modules);
// Find all labs from the sessions, convert to summaries, and filter.
var labs = es.filterLabs(
getLabSummariesFromSessions(sessions, s -> true),
queueSessionTypes, modules);
// Sort all labs
labs = es.sortLabs(labs);
model.addAttribute("edition", edition);
@@ -501,22 +509,6 @@ public class EditionController {
return "edition/view/status :: #assistant-table";
}
/**
* Gets lab views for the given list of sessions after applying the given predicate.
*
* @param sessions The sessions that are to be displayed through lab view DTOs.
* @param p The predicate to apply to the sessions to filter out the relevant labs.
* @return The list of LabViewDTOs representing the selected sessions (and labs).
*/
private List<QueueSessionSummaryDTO> getLabSummariesFromSessions(List<SessionDetailsDTO> sessions,
Predicate<SessionDetailsDTO> p) {
return View.convert(lr.findAllBySessions(
sessions.stream().filter(p)
.map(SessionDetailsDTO::getId)
.collect(Collectors.toList())),
QueueSessionSummaryDTO.class);
}
/**
*
* @param courseId Id of the course to which the edition should be added
@@ -558,4 +550,20 @@ public class EditionController {
return "redirect:/edition/" + id;
}
/**
* Gets lab views for the given list of sessions after applying the given predicate.
*
* @param sessions The sessions that are to be displayed through lab view DTOs.
* @param p The predicate to apply to the sessions to filter out the relevant labs.
* @return The list of LabViewDTOs representing the selected sessions (and labs).
*/
private List<QueueSessionSummaryDTO> getLabSummariesFromSessions(List<SessionDetailsDTO> sessions,
Predicate<SessionDetailsDTO> p) {
return View.convert(lr.findAllBySessions(
sessions.stream().filter(p)
.map(SessionDetailsDTO::getId)
.collect(Collectors.toList())),
QueueSessionSummaryDTO.class);
}
}
Loading