diff --git a/src/util/model/member.rs b/src/util/model/member.rs index 2e0596f..de56628 100644 --- a/src/util/model/member.rs +++ b/src/util/model/member.rs @@ -1,7 +1,6 @@ #[cfg(feature = "server")] use crate::util::surrealdb::DB; use serde::{Deserialize, Serialize}; -use std::collections::BTreeSet; #[cfg(feature = "server")] mod migration; @@ -10,10 +9,10 @@ mod migration; pub struct Member { pub id: String, pub name: Name, - // pub hours: BTreeSet, - // pub groups: BTreeSet, - // pub diploma: Option, - // pub registration_token: Option, + pub hours: Vec, + pub groups: Vec, + pub diploma: Option, + pub registration_token: Option, } #[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)] diff --git a/src/util/model/member/migration.rs b/src/util/model/member/migration.rs index e88c099..3ed0a23 100644 --- a/src/util/model/member/migration.rs +++ b/src/util/model/member/migration.rs @@ -64,16 +64,16 @@ impl Row { first: self.first_name.clone(), full: self.generate_full_name(), }, - // hours: self.generate_hours(), - // groups: BTreeSet::new(), - // diploma: self.diploma.clone(), - // registration_token: None, + hours: self.generate_hours(), + groups: Vec::new(), + diploma: self.diploma.clone(), + registration_token: None, } } // Get the hour data from the raw string - fn generate_hours(&self) -> BTreeSet { - let mut hours: BTreeSet = BTreeSet::new(); + fn generate_hours(&self) -> Vec { + let mut hours: Vec = Vec::new(); let group_parts: Vec<&str> = self.hours.split(", ").collect(); @@ -82,7 +82,7 @@ impl Row { for part in hour_parts { if &*part != "Groep" { - hours.insert(part.to_string()); + hours.push(part.to_string()); } } } @@ -164,10 +164,10 @@ fn combine_members_lists( updated_members.push(Member { id: current_member.id, name: new_member_clone.name, - // hours: new_member_clone.hours, - // groups: current_member.groups, - // diploma: new_member_clone.diploma, - // registration_token: current_member.diploma, + hours: new_member_clone.hours, + groups: current_member.groups, + diploma: new_member_clone.diploma, + registration_token: current_member.diploma, }) } else { // Remove member @@ -221,8 +221,8 @@ impl Member { // TODO add hours and diploma support query = query + format!( - "UPDATE member:{} SET name.first = \"{}\", name.full = \"{}\";", - member.id, member.name.first, member.name.full + "UPDATE member:{} SET name.first = \"{}\", name.full = \"{}\", hours = {:?}, groups = {:?};", + member.id, member.name.first, member.name.full, member.hours, member.groups ) .as_str(); } @@ -231,8 +231,8 @@ impl Member { // TODO add hours and diploma support query = query + format!( - "CREATE member:{} SET name.first = \"{}\", name.full = \"{}\";", - member.id, member.name.first, member.name.full + "CREATE member:{} SET name.first = \"{}\", name.full = \"{}\", hours = {:?}, groups = {:?};", + member.id, member.name.first, member.name.full, member.hours, member.groups ) .as_str(); } @@ -267,14 +267,14 @@ mod tests { first: "First".to_string(), full: "First Last".to_string(), }, - // hours: BTreeSet::from([ - // "Wedstrijd".to_string(), - // "Z5".to_string(), - // "Zaterdag".to_string(), - // ]), - // groups: BTreeSet::new(), - // diploma: Some("LS1".to_string()), - // registration_token: None, + hours: Vec::from([ + "Wedstrijd".to_string(), + "Z5".to_string(), + "Zaterdag".to_string(), + ]), + groups: vec![], + diploma: Some("LS1".to_string()), + registration_token: None, }, Member { id: "D000002".to_string(), @@ -282,10 +282,10 @@ mod tests { first: "First2".to_string(), full: "First2 Last2".to_string(), }, - // hours: BTreeSet::from(["Z5".to_string(), "Zaterdag".to_string()]), - // groups: BTreeSet::new(), - // diploma: Some("ZR4".to_string()), - // registration_token: None, + hours: Vec::from(["Z5".to_string(), "Zaterdag".to_string()]), + groups: Vec::new(), + diploma: Some("ZR4".to_string()), + registration_token: None, }, ];