From 3257bf366067b0e3c2bed979dcd42c52c70ce017 Mon Sep 17 00:00:00 2001 From: Ben Edwards <147524406+Ben-Edwards-cgi@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:17:33 +0100 Subject: [PATCH] Updated the way we show the jurors location to only show if they are checked in or on a trial (#745) --- .../response/JurorOverviewResponseDto.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/controller/response/JurorOverviewResponseDto.java b/src/main/java/uk/gov/hmcts/juror/api/moj/controller/response/JurorOverviewResponseDto.java index 7fdad8616..7025cc0a2 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/moj/controller/response/JurorOverviewResponseDto.java +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/controller/response/JurorOverviewResponseDto.java @@ -127,7 +127,7 @@ public JurorOverviewResponseDto(JurorPool jurorPool, if (todayAppearance.isPresent() && todayAppearance.get().getTimeOut() != null) { this.location = null; } else { - this.location = getLocationFromPanel(panelRepository, jurorPool); + this.location = getLocationFromPanel(panelRepository, jurorPool, this.checkedInTodayTime != null); } @@ -158,12 +158,16 @@ public JurorOverviewResponseDto(JurorPool jurorPool, } @JsonIgnore - private String getLocationFromPanel(PanelRepository panelRepository, JurorPool jurorPool) { - return getActivePanel(panelRepository, jurorPool) - .map(panel -> panel.getTrial().getCourtroom().getDescription()) - .orElse(Optional.ofNullable(jurorPool.getCourt().getAssemblyRoom()) + private String getLocationFromPanel(PanelRepository panelRepository, JurorPool jurorPool, boolean hasAppearance) { + Optional locationFromPanel = getActivePanel(panelRepository, jurorPool) + .map(panel -> panel.getTrial().getCourtroom().getDescription()); + + if (locationFromPanel.isPresent() || !hasAppearance) { + return locationFromPanel.orElse(null); + } + return Optional.ofNullable(jurorPool.getCourt().getAssemblyRoom()) .map(Courtroom::getDescription) - .orElse(null)); + .orElse(null); } private Optional getActivePanel(PanelRepository panelRepository, JurorPool jurorPool) {