|
1 | 1 | //! This module defines the logic to calculate vote results. |
2 | 2 |
|
3 | | -use std::{collections::HashMap, fmt}; |
| 3 | +use std::{collections::BTreeMap, fmt}; |
4 | 4 |
|
5 | 5 | use anyhow::{bail, Result}; |
6 | 6 | use serde::{Deserialize, Serialize}; |
@@ -113,7 +113,7 @@ pub(crate) struct VoteResults { |
113 | 113 | pub binding: i64, |
114 | 114 | pub non_binding: i64, |
115 | 115 | pub allowed_voters: i64, |
116 | | - pub votes: HashMap<UserName, UserVote>, |
| 116 | + pub votes: BTreeMap<UserName, UserVote>, |
117 | 117 | pub pending_voters: Vec<UserName>, |
118 | 118 | } |
119 | 119 |
|
@@ -141,7 +141,7 @@ pub(crate) async fn calculate<'a>( |
141 | 141 | gh.get_allowed_voters(inst_id, &vote.cfg, owner, repo, vote.organization.as_ref()).await?; |
142 | 142 |
|
143 | 143 | // Track users votes |
144 | | - let mut votes: HashMap<UserName, UserVote> = HashMap::new(); |
| 144 | + let mut votes: BTreeMap<UserName, UserVote> = BTreeMap::new(); |
145 | 145 | let mut multiple_options_voters: Vec<UserName> = Vec::new(); |
146 | 146 | for reaction in reactions { |
147 | 147 | // Get vote option from reaction |
@@ -345,7 +345,7 @@ mod tests { |
345 | 345 | not_voted: 0, |
346 | 346 | binding: 1, |
347 | 347 | non_binding: 0, |
348 | | - votes: HashMap::from([ |
| 348 | + votes: BTreeMap::from([ |
349 | 349 | ( |
350 | 350 | USER1.to_string(), |
351 | 351 | UserVote { |
@@ -393,7 +393,7 @@ mod tests { |
393 | 393 | not_voted: 1, |
394 | 394 | binding: 0, |
395 | 395 | non_binding: 0, |
396 | | - votes: HashMap::new(), |
| 396 | + votes: BTreeMap::new(), |
397 | 397 | allowed_voters: 1, |
398 | 398 | pending_voters: vec![USER1.to_string()], |
399 | 399 | } |
@@ -445,7 +445,7 @@ mod tests { |
445 | 445 | not_voted: 1, |
446 | 446 | binding: 3, |
447 | 447 | non_binding: 1, |
448 | | - votes: HashMap::from([ |
| 448 | + votes: BTreeMap::from([ |
449 | 449 | ( |
450 | 450 | USER1.to_string(), |
451 | 451 | UserVote { |
@@ -525,7 +525,7 @@ mod tests { |
525 | 525 | not_voted: 1, |
526 | 526 | binding: 3, |
527 | 527 | non_binding: 0, |
528 | | - votes: HashMap::from([ |
| 528 | + votes: BTreeMap::from([ |
529 | 529 | ( |
530 | 530 | USER1.to_string(), |
531 | 531 | UserVote { |
|
0 commit comments