mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-18 14:01:04 +00:00
feat: csv export all data
This commit is contained in:
parent
9943b6aff7
commit
29ce46106f
7 changed files with 45 additions and 6 deletions
|
|
@ -256,7 +256,6 @@ pub mod tests {
|
|||
))
|
||||
.dispatch();
|
||||
|
||||
println!("{:?}", response);
|
||||
(
|
||||
response.cookies().get("id").unwrap().to_owned(),
|
||||
response.cookies().get("key").unwrap().to_owned(),
|
||||
|
|
|
|||
|
|
@ -58,6 +58,15 @@ pub struct ApplicationRow {
|
|||
pub school_name: Option<String>,
|
||||
pub health_insurance: Option<String>,
|
||||
|
||||
pub diploma_1_8: String,
|
||||
pub diploma_2_8: String,
|
||||
pub diploma_1_9: String,
|
||||
|
||||
pub first_school_name: Option<String>,
|
||||
pub first_school_field: Option<String>,
|
||||
pub second_school_name: Option<String>,
|
||||
pub second_school_field: Option<String>,
|
||||
|
||||
pub parent_name: Option<String>,
|
||||
pub parent_surname: Option<String>,
|
||||
pub parent_telephone: Option<String>,
|
||||
|
|
|
|||
|
|
@ -184,8 +184,6 @@ impl EncryptedCandidateDetails {
|
|||
EncryptedString::decrypt_option(&self.second_school, priv_key), // 14
|
||||
)?;
|
||||
|
||||
println!("d: {:?}", d.12);
|
||||
|
||||
Ok(CandidateDetails {
|
||||
name: d.0.unwrap_or_default(),
|
||||
surname: d.1.unwrap_or_default(),
|
||||
|
|
|
|||
|
|
@ -16,6 +16,23 @@ impl GradeList {
|
|||
|grades| serde_json::from_str(&grades).unwrap() // TODO: handle error
|
||||
)
|
||||
}
|
||||
|
||||
pub fn group_by_semester(&self) -> (GradeList, GradeList, GradeList) {
|
||||
let mut first_semester = GradeList::default();
|
||||
let mut second_semester = GradeList::default();
|
||||
let mut third_semester = GradeList::default();
|
||||
|
||||
for grade in &self.0 {
|
||||
match grade.semester.as_str() {
|
||||
"1/8" => first_semester.0.push(grade.clone()),
|
||||
"2/8" => second_semester.0.push(grade.clone()),
|
||||
"1/9" => third_semester.0.push(grade.clone()),
|
||||
_ => panic!("Invalid semester"),
|
||||
}
|
||||
}
|
||||
|
||||
(first_semester, second_semester, third_semester)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for GradeList {
|
||||
|
|
|
|||
|
|
@ -8,11 +8,18 @@ pub struct School {
|
|||
|
||||
impl School {
|
||||
pub fn from_opt_str(school: Option<String>) -> Option<Self> {
|
||||
println!("School: {:?}", school);
|
||||
school.map(
|
||||
|school| serde_json::from_str(&school).unwrap() // TODO: handle error
|
||||
)
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
|
||||
pub fn field(&self) -> &str {
|
||||
&self.field
|
||||
}
|
||||
}
|
||||
|
||||
impl ToString for School {
|
||||
|
|
|
|||
|
|
@ -77,7 +77,6 @@ mod tests {
|
|||
)
|
||||
.await
|
||||
.unwrap();
|
||||
// println!("{}", session.err().unwrap().1);
|
||||
assert!(
|
||||
ApplicationService::auth(db, Uuid::parse_str(&session).unwrap())
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use sea_orm::DbConn;
|
|||
impl From<(i32, ApplicationDetails)> for ApplicationRow {
|
||||
fn from((application, d): (i32, ApplicationDetails)) -> Self {
|
||||
let c = d.candidate;
|
||||
let (diploma_1_8, diploma_2_8, diploma_1_9) = c.grades.group_by_semester();
|
||||
Self {
|
||||
application,
|
||||
name: Some(c.name),
|
||||
|
|
@ -20,9 +21,18 @@ impl From<(i32, ApplicationDetails)> for ApplicationRow {
|
|||
citizenship: Some(c.citizenship),
|
||||
email: Some(c.email),
|
||||
sex: Some(c.sex),
|
||||
personal_identification_number: Some(c.personal_id_number),
|
||||
health_insurance: Some(c.health_insurance),
|
||||
school_name: Some(c.school_name),
|
||||
personal_identification_number: Some(c.personal_id_number),
|
||||
|
||||
diploma_1_8: diploma_1_8.to_string(),
|
||||
diploma_2_8: diploma_2_8.to_string(),
|
||||
diploma_1_9: diploma_1_9.to_string(),
|
||||
|
||||
first_school_name: Some(c.first_school.name().to_owned()),
|
||||
first_school_field: Some(c.first_school.field().to_owned()),
|
||||
second_school_name: Some(c.second_school.name().to_owned()),
|
||||
second_school_field: Some(c.second_school.field().to_owned()),
|
||||
|
||||
parent_name: d.parents.get(0).map(|p| p.name.clone()),
|
||||
parent_surname: d.parents.get(0).map(|p| p.surname.clone()),
|
||||
|
|
|
|||
Loading…
Reference in a new issue