From 3b1fb167dce16af8e4b1fcb07158d4c5207fb029 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Sun, 6 Aug 2023 16:28:07 +0200 Subject: [PATCH] Provide allocated seat numbers in result --- .../twomartens/wahlrecht/model/dto/v1/ElectedCandidates.kt | 3 ++- .../twomartens/wahlrecht/model/internal/ElectedCandidates.kt | 3 ++- .../de/twomartens/wahlrecht/service/CalculationService.kt | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/module-server/src/main/kotlin/de/twomartens/wahlrecht/model/dto/v1/ElectedCandidates.kt b/module-server/src/main/kotlin/de/twomartens/wahlrecht/model/dto/v1/ElectedCandidates.kt index 7668ade..abb5eca 100644 --- a/module-server/src/main/kotlin/de/twomartens/wahlrecht/model/dto/v1/ElectedCandidates.kt +++ b/module-server/src/main/kotlin/de/twomartens/wahlrecht/model/dto/v1/ElectedCandidates.kt @@ -2,4 +2,5 @@ package de.twomartens.wahlrecht.model.dto.v1 data class ElectedCandidates(val overallResult: ElectedResult, val constituencyResults: Map, - val electionNumbersForSeatAllocation: List) + val electionNumbersForSeatAllocation: List, + val seatAllocation: Map) diff --git a/module-server/src/main/kotlin/de/twomartens/wahlrecht/model/internal/ElectedCandidates.kt b/module-server/src/main/kotlin/de/twomartens/wahlrecht/model/internal/ElectedCandidates.kt index 6744f62..d676dc0 100644 --- a/module-server/src/main/kotlin/de/twomartens/wahlrecht/model/internal/ElectedCandidates.kt +++ b/module-server/src/main/kotlin/de/twomartens/wahlrecht/model/internal/ElectedCandidates.kt @@ -2,4 +2,5 @@ package de.twomartens.wahlrecht.model.internal data class ElectedCandidates(val overallResult: ElectedResult, val constituencyResults: Map, - val electionNumbersForSeatAllocation: List) + val electionNumbersForSeatAllocation: List, + val seatAllocation: Map) diff --git a/module-server/src/main/kotlin/de/twomartens/wahlrecht/service/CalculationService.kt b/module-server/src/main/kotlin/de/twomartens/wahlrecht/service/CalculationService.kt index bedfbb5..c49f6d6 100644 --- a/module-server/src/main/kotlin/de/twomartens/wahlrecht/service/CalculationService.kt +++ b/module-server/src/main/kotlin/de/twomartens/wahlrecht/service/CalculationService.kt @@ -51,7 +51,10 @@ class CalculationService( return ElectedCandidates( overallResult = overallElectedCandidates, constituencyResults = constituencyResults, - electionNumbersForSeatAllocation = seatResult.usedElectionNumbers + electionNumbersForSeatAllocation = seatResult.usedElectionNumbers, + seatAllocation = seatResult.seatsPerNomination + .map { Pair(it.key.partyAbbreviation, it.value) } + .toMap() ) }