Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Juror showing with a room location when they have not yet attended #745

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down Expand Up @@ -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<String> 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<Panel> getActivePanel(PanelRepository panelRepository, JurorPool jurorPool) {
Expand Down