Added support for groups and hours
This commit is contained in:
parent
feeb0facfc
commit
b36fb6af89
@ -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<String>,
|
||||
// pub groups: BTreeSet<String>,
|
||||
// pub diploma: Option<String>,
|
||||
// pub registration_token: Option<String>,
|
||||
pub hours: Vec<String>,
|
||||
pub groups: Vec<String>,
|
||||
pub diploma: Option<String>,
|
||||
pub registration_token: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
|
||||
|
@ -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<String> {
|
||||
let mut hours: BTreeSet<String> = BTreeSet::new();
|
||||
fn generate_hours(&self) -> Vec<String> {
|
||||
let mut hours: Vec<String> = 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,
|
||||
},
|
||||
];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user