vote_chart: sort parsed votes

The SQL query retrieving the votes is deterministicly sorted, but goes through
a HashMap, for ease of processing and transfer, which does not maintaing order.

Sort the resulting object in the Javascript to keep a consistent order in the graph.
This commit is contained in:
trotFunky 2024-07-24 15:23:52 +01:00
parent 8547312a78
commit 982a7ffd65
2 changed files with 6 additions and 0 deletions

View file

@ -115,6 +115,8 @@ pub async fn fetch_vote_data(week: u8, mut db: Connection<database::Db>) -> Opti
}
// The hash map makes storing and retrieving the data really easy, *but*
// it does lose the order of the original array (which is sorted via the SQL).
let mut vote_data = HashMap::<String, Vec<u8>>::new();
let mut next_truth_number = 1;
for raw_vote in raw_votes {