Skip to content

Commit

Permalink
Implement Kieswet article P 9 (#1051)
Browse files Browse the repository at this point in the history
Co-authored-by: cikzh <marlonpeeters@tweedegolf.com>
Co-authored-by: Mark Janssen <20283+praseodym@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 25, 2025
1 parent 1d7c518 commit aa22014
Show file tree
Hide file tree
Showing 14 changed files with 1,222 additions and 122 deletions.
67 changes: 65 additions & 2 deletions backend/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,28 @@
},
"components": {
"schemas": {
"AbsoluteMajorityChange": {
"type": "object",
"description": "Contains information about the enactment of article P 9 of the Kieswet.",
"required": [
"pg_retracted_seat",
"pg_assigned_seat"
],
"properties": {
"pg_assigned_seat": {
"type": "integer",
"format": "int32",
"description": "Political group number which the residual seat is assigned to",
"minimum": 0
},
"pg_retracted_seat": {
"type": "integer",
"format": "int32",
"description": "Political group number which the residual seat is retracted from",
"minimum": 0
}
}
},
"ApportionmentResult": {
"type": "object",
"description": "The result of the apportionment procedure. This contains the number of seats and the quota\nthat was used. It then contains the initial standing after whole seats were assigned,\nand each of the changes and intermediate standings. The final standing contains the\nnumber of seats per political group that was assigned after all seats were assigned.",
Expand Down Expand Up @@ -1510,6 +1532,27 @@
}
}
]
},
{
"allOf": [
{
"$ref": "#/components/schemas/AbsoluteMajorityChange"
},
{
"type": "object",
"required": [
"assigned_by"
],
"properties": {
"assigned_by": {
"type": "string",
"enum": [
"AbsoluteMajorityChange"
]
}
}
}
]
}
],
"description": "Records the political group and specific change for a specific residual seat"
Expand Down Expand Up @@ -2106,17 +2149,27 @@
"required": [
"selected_pg_number",
"pg_options",
"pg_assigned",
"votes_per_seat"
],
"properties": {
"pg_assigned": {
"type": "array",
"items": {
"type": "integer",
"format": "int32",
"minimum": 0
},
"description": "The list of political groups with the same average, that have been assigned a seat"
},
"pg_options": {
"type": "array",
"items": {
"type": "integer",
"format": "int32",
"minimum": 0
},
"description": "The list from which the political group was selected, all of them having the same votes per seat"
"description": "The list of political groups with the same average, that have not been assigned a seat"
},
"selected_pg_number": {
"type": "integer",
Expand All @@ -2136,17 +2189,27 @@
"required": [
"selected_pg_number",
"pg_options",
"pg_assigned",
"surplus_votes"
],
"properties": {
"pg_assigned": {
"type": "array",
"items": {
"type": "integer",
"format": "int32",
"minimum": 0
},
"description": "The list of political groups with the same surplus, that have been assigned a seat"
},
"pg_options": {
"type": "array",
"items": {
"type": "integer",
"format": "int32",
"minimum": 0
},
"description": "The list from which the political group was selected, all of them having the same number of surplus votes"
"description": "The list of political groups with the same surplus, that have not been assigned a seat"
},
"selected_pg_number": {
"type": "integer",
Expand Down
4 changes: 2 additions & 2 deletions backend/src/apportionment/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use utoipa::ToSchema;

use crate::{
APIError, ErrorResponse,
apportionment::{ApportionmentError, ApportionmentResult, seat_allocation},
apportionment::{ApportionmentError, ApportionmentResult, apportionment},
data_entry::{
repository::{PollingStationDataEntries, PollingStationResultsEntries},
status::DataEntryStatusName,
Expand Down Expand Up @@ -56,7 +56,7 @@ pub async fn election_apportionment(
.list_with_polling_stations(polling_stations_repo, election.id)
.await?;
let election_summary = ElectionSummary::from_results(&election, &results)?;
let apportionment = seat_allocation(election.number_of_seats.into(), &election_summary)?;
let apportionment = apportionment(election.number_of_seats.into(), &election_summary)?;
Ok(Json(ElectionApportionmentResponse {
apportionment,
election_summary,
Expand Down
Loading

0 comments on commit aa22014

Please sign in to comment.