Problem: At the moment, the dates[] array is just sorted in the order we add the ballots in.
This means that we can do something like
|
MULTIPLE_BALLOTS_WITH_VOTING_SYSTEM_AND_POLLING_STATION = ( |
|
RootBuilder() |
|
.with_multiple_ballots( |
|
[ |
|
MAYOR_BALLOT.with_candidates(candidates.all_candidates).build(), |
|
GLA_BALLOT.with_candidates(candidates.all_candidates).build(), |
|
] |
|
) |
|
.with_polling_station(WITHOUT_MAP_POLLING_STATION.build()) |
|
.with_electoral_services(electoral_services.stroud_electoral_services) |
|
) |
In this example, the GLA_BALLOT has a date before the MAYOR_BALLOT
|
GLA_BALLOT = ( |
|
StockLocalBallotBuilder() |
|
.with_ballot_title("London Assembly elections") |
|
.with_post_name("London Assembly") |
|
.with_election_name("London Assembly elections") |
|
.with_ballot_paper_id("gla.a.2024-05-02") |
|
.with_election_id("gla.a.2024-05-02") |
|
) |
|
MAYOR_BALLOT = ( |
|
StockLocalBallotBuilder() |
|
.with_ballot_title("Mayor of London") |
|
.with_post_name("Mayor of London") |
|
.with_election_name("Mayor of London") |
|
.with_ballot_paper_id("mayor.london.2024-11-02") |
|
.with_election_id("mayor.london.2024-11-02") |
|
.with_voting_system("FPTP") |
|
.with_candidates(candidates.all_candidates) |
|
) |
but because we add it second, it comes after it in the dates array. This is unexpected by client apps, the set_date_baseline() function, etc.
Solution: We should ensure that whatever order we add ballots in (either using .with_multiple_ballots() or chained calls to with_ballot() the ballots come out in chronological order in the final response.
Problem: At the moment, the
dates[]array is just sorted in the order we add the ballots in.This means that we can do something like
dc_response_builder/response_builder/v1/generated_responses/root_responses.py
Lines 68 to 78 in e22b430
In this example, the
GLA_BALLOThas a date before theMAYOR_BALLOTdc_response_builder/response_builder/v1/generated_responses/ballots.py
Lines 18 to 25 in e22b430
dc_response_builder/response_builder/v1/generated_responses/ballots.py
Lines 40 to 49 in e22b430
but because we add it second, it comes after it in the
datesarray. This is unexpected by client apps, theset_date_baseline()function, etc.Solution: We should ensure that whatever order we add ballots in (either using
.with_multiple_ballots()or chained calls towith_ballot()the ballots come out in chronological order in the final response.