diff --git a/api/src/routes/admin.rs b/api/src/routes/admin.rs index 0291e4b..1310511 100644 --- a/api/src/routes/admin.rs +++ b/api/src/routes/admin.rs @@ -256,7 +256,6 @@ pub mod tests { )) .dispatch(); - println!("{:?}", response); ( response.cookies().get("id").unwrap().to_owned(), response.cookies().get("key").unwrap().to_owned(), diff --git a/core/src/models/application.rs b/core/src/models/application.rs index 6cbb328..6224cf0 100644 --- a/core/src/models/application.rs +++ b/core/src/models/application.rs @@ -58,6 +58,15 @@ pub struct ApplicationRow { pub school_name: Option, pub health_insurance: Option, + pub diploma_1_8: String, + pub diploma_2_8: String, + pub diploma_1_9: String, + + pub first_school_name: Option, + pub first_school_field: Option, + pub second_school_name: Option, + pub second_school_field: Option, + pub parent_name: Option, pub parent_surname: Option, pub parent_telephone: Option, diff --git a/core/src/models/candidate_details.rs b/core/src/models/candidate_details.rs index ebe85fc..56b4ee7 100644 --- a/core/src/models/candidate_details.rs +++ b/core/src/models/candidate_details.rs @@ -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(), diff --git a/core/src/models/grade.rs b/core/src/models/grade.rs index d58a18a..acd72b7 100644 --- a/core/src/models/grade.rs +++ b/core/src/models/grade.rs @@ -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 { diff --git a/core/src/models/school.rs b/core/src/models/school.rs index 3a3ceed..27c18d6 100644 --- a/core/src/models/school.rs +++ b/core/src/models/school.rs @@ -8,11 +8,18 @@ pub struct School { impl School { pub fn from_opt_str(school: Option) -> Option { - 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 { diff --git a/core/src/services/session_service.rs b/core/src/services/session_service.rs index 30321d7..eacc31d 100644 --- a/core/src/services/session_service.rs +++ b/core/src/services/session_service.rs @@ -77,7 +77,6 @@ mod tests { ) .await .unwrap(); - // println!("{}", session.err().unwrap().1); assert!( ApplicationService::auth(db, Uuid::parse_str(&session).unwrap()) .await diff --git a/core/src/utils/csv.rs b/core/src/utils/csv.rs index ce6827f..61b7e1c 100644 --- a/core/src/utils/csv.rs +++ b/core/src/utils/csv.rs @@ -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()),