diff --git a/api/src/routes/candidate.rs b/api/src/routes/candidate.rs index 832b704..ed3e0aa 100644 --- a/api/src/routes/candidate.rs +++ b/api/src/routes/candidate.rs @@ -310,8 +310,7 @@ mod tests { \"sex\": \"MALE\", \"personalIdNumber\": \"0101010000\", \"schoolName\": \"29988383\", - \"healthInsurance\": \"000\", - \"study\": \"KB\" + \"healthInsurance\": \"000\" }, \"parents\": [ { diff --git a/core/src/database/mutation/candidate.rs b/core/src/database/mutation/candidate.rs index bb9f802..8dac3f3 100644 --- a/core/src/database/mutation/candidate.rs +++ b/core/src/database/mutation/candidate.rs @@ -54,7 +54,6 @@ impl Mutation { candidate.personal_identification_number = Set(enc_candidate.personal_id_number.map(|e| e.into()).unwrap_or_default()); // TODO: do not set this here, it is already set in the create_candidate mutation??? candidate.school_name = Set(enc_candidate.school_name.map(|e| e.into())); candidate.health_insurance = Set(enc_candidate.health_insurance.map(|e| e.into())); - candidate.study = Set(enc_candidate.study.map(|e| e.into())); candidate.encrypted_by_id = Set(Some(encrypted_by_id)); candidate.updated_at = Set(chrono::offset::Local::now().naive_local()); @@ -127,6 +126,6 @@ mod tests { .await .unwrap().unwrap(); - assert!(candidate.study.is_some()); + assert!(candidate.name.is_some()); } } diff --git a/core/src/database/query/application.rs b/core/src/database/query/application.rs index 2ec4077..4b2baef 100644 --- a/core/src/database/query/application.rs +++ b/core/src/database/query/application.rs @@ -10,7 +10,6 @@ pub struct ApplicationCandidateJoin { pub surname: Option, pub email: Option, pub telephone: Option, - pub study: Option, } use crate::Query; @@ -47,7 +46,6 @@ impl Query { .column_as(candidate::Column::Surname, "surname") .column_as(candidate::Column::Email, "email") .column_as(candidate::Column::Telephone, "telephone") - .column_as(candidate::Column::Study, "study") .into_model::() .all(db) .await diff --git a/core/src/database/query/candidate.rs b/core/src/database/query/candidate.rs index 6f32d21..461a802 100644 --- a/core/src/database/query/candidate.rs +++ b/core/src/database/query/candidate.rs @@ -44,30 +44,6 @@ impl Query { .await } - pub async fn list_candidates_preview( - db: &DbConn, - field_of_study_opt: Option, - page: Option, - ) -> Result, DbErr> { - let select = Candidate::find(); - let query = if let Some(study) = field_of_study_opt { - select.filter(candidate::Column::Study.eq(study)) - } else { - select - } - .order_by(candidate::Column::Id, Order::Asc) - .into_model::(); - - if let Some(page) = page { - query - .paginate(db, PAGE_SIZE) - .fetch_page(page).await - } else { - query - .all(db).await - } - } - pub async fn list_candidates_full( db: &DbConn ) -> Result, DbErr> { diff --git a/core/src/models/application.rs b/core/src/models/application.rs index 3ca4da8..8597e34 100644 --- a/core/src/models/application.rs +++ b/core/src/models/application.rs @@ -14,7 +14,6 @@ pub struct ApplicationResponse { pub surname: String, pub email: String, pub telephone: String, - pub study: String, } impl ApplicationResponse { @@ -34,7 +33,6 @@ impl ApplicationResponse { surname: surname.unwrap_or_default(), email: email.unwrap_or_default(), telephone: telephone.unwrap_or_default(), - study: c.study.unwrap_or_default(), candidate_id: c.candidate_id, } ) diff --git a/core/src/models/candidate.rs b/core/src/models/candidate.rs index 9a72cc7..38b7cc7 100644 --- a/core/src/models/candidate.rs +++ b/core/src/models/candidate.rs @@ -50,7 +50,6 @@ pub struct CandidateDetails { pub citizenship: String, pub email: String, pub sex: String, - pub study: String, pub personal_id_number: String, pub school_name: String, pub health_insurance: String, diff --git a/core/src/models/candidate_details.rs b/core/src/models/candidate_details.rs index 4a55f89..2ac72c2 100644 --- a/core/src/models/candidate_details.rs +++ b/core/src/models/candidate_details.rs @@ -26,7 +26,6 @@ pub struct EncryptedCandidateDetails { pub personal_id_number: Option, pub school_name: Option, pub health_insurance: Option, - pub study: Option, } #[derive(Debug, Clone)] @@ -148,7 +147,6 @@ impl EncryptedCandidateDetails { personal_id_number: d.9, school_name: d.10, health_insurance: d.11, - study: Some(form.study.clone()), } ) } @@ -182,7 +180,6 @@ impl EncryptedCandidateDetails { personal_id_number: d.9.unwrap_or_default(), school_name: d.10.unwrap_or_default(), health_insurance: d.11.unwrap_or_default(), - study: self.study.clone().unwrap_or_default(), } ) } @@ -197,8 +194,7 @@ impl EncryptedCandidateDetails { self.citizenship.is_some() && self.email.is_some() && self.sex.is_some() && - self.personal_id_number.is_some() && - self.study.is_some() + self.personal_id_number.is_some() } } impl From<&candidate::Model> for EncryptedCandidateDetails { @@ -218,7 +214,6 @@ impl From<&candidate::Model> for EncryptedCandidateDetails { personal_id_number: Some(EncryptedString::from(candidate.personal_identification_number.to_owned())), school_name: EncryptedString::try_from(&candidate.school_name).ok(), health_insurance: EncryptedString::try_from(&candidate.health_insurance).ok(), - study: candidate.study.clone(), } } } @@ -356,7 +351,6 @@ impl TryFrom for EncryptedApplicationDetails { personal_id_number: EncryptedString::try_from(&cp.personal_identification_number).ok(), school_name: EncryptedString::try_from(&cp.school_name).ok(), health_insurance: EncryptedString::try_from(&cp.health_insurance).ok(), - study: cp.study.ok_or(ServiceError::CandidateDetailsNotSet).ok(), }, parents: vec![EncryptedParentDetails { name: EncryptedString::try_from(&cp.parent_name).ok(), @@ -410,7 +404,6 @@ pub mod tests { personal_id_number: "personal_id_number".to_string(), school_name: "school_name".to_string(), health_insurance: "health_insurance".to_string(), - study: "study".to_string(), }, parents: vec![ParentDetails { name: "parent_name".to_string(), @@ -431,7 +424,6 @@ pub mod tests { assert_eq!(details.candidate.citizenship, "citizenship"); assert_eq!(details.candidate.email, "email"); assert_eq!(details.candidate.sex, "sex"); - assert_eq!(details.candidate.study, "study"); assert_eq!(details.candidate.personal_id_number, "personal_id_number"); for parent in &details.parents { assert_eq!(parent.name, "parent_name"); diff --git a/core/src/services/candidate_service.rs b/core/src/services/candidate_service.rs index 7bc4828..f622c08 100644 --- a/core/src/services/candidate_service.rs +++ b/core/src/services/candidate_service.rs @@ -56,32 +56,6 @@ impl CandidateService { ).await?; Ok(model) } - - pub async fn list_candidates( - private_key: &String, - db: &DbConn, - field_of_study: Option, - page: Option, - ) -> Result, ServiceError> { - - let candidates = Query::list_candidates_preview( - db, - field_of_study, - page - ).await?; - - futures::future::try_join_all( - candidates - .iter() - .map(|c| async move { - BaseCandidateResponse::from_encrypted( - private_key, - c.clone(), - PortfolioService::get_submission_progress(c.application).await.ok() - ).await - }) - ).await - } } #[cfg(test)] diff --git a/core/src/services/parent_service.rs b/core/src/services/parent_service.rs index fd3cb2e..fbce151 100644 --- a/core/src/services/parent_service.rs +++ b/core/src/services/parent_service.rs @@ -71,7 +71,6 @@ mod tests { personal_id_number: "personal_id_number".to_string(), school_name: "school_name".to_string(), health_insurance: "health_insurance".to_string(), - study: "study".to_string(), }, parents: vec![ParentDetails { name: "parent_name".to_string(), diff --git a/core/src/utils/csv.rs b/core/src/utils/csv.rs index 6c3a3b2..4a48a82 100644 --- a/core/src/utils/csv.rs +++ b/core/src/utils/csv.rs @@ -15,7 +15,7 @@ impl From<(i32, ApplicationDetails)> for Row { citizenship: Some(c.citizenship), email: Some(c.email), sex: Some(c.sex), - study: Some(c.study), + study: Some("TODO".to_string()), health_insurance: Some(c.health_insurance), school_name: Some(c.school_name), personal_identification_number: Some(c.personal_id_number), diff --git a/entity/src/candidate.rs b/entity/src/candidate.rs index c1a1d77..9f88ce3 100644 --- a/entity/src/candidate.rs +++ b/entity/src/candidate.rs @@ -17,7 +17,6 @@ pub struct Model { pub citizenship: Option, pub email: Option, pub sex: Option, - pub study: Option, pub personal_identification_number: String, pub school_name: Option, pub health_insurance: Option, diff --git a/migration/src/m20221024_121621_create_candidate.rs b/migration/src/m20221024_121621_create_candidate.rs index 0b4f77b..3a745d9 100644 --- a/migration/src/m20221024_121621_create_candidate.rs +++ b/migration/src/m20221024_121621_create_candidate.rs @@ -28,7 +28,6 @@ impl MigrationTrait for Migration { .col(ColumnDef::new(Candidate::Citizenship).string()) .col(ColumnDef::new(Candidate::Email).string()) .col(ColumnDef::new(Candidate::Sex).string()) - .col(ColumnDef::new(Candidate::Study).string()) .col(ColumnDef::new(Candidate::PersonalIdentificationNumber).string().not_null()) .col(ColumnDef::new(Candidate::SchoolName).string()) .col(ColumnDef::new(Candidate::HealthInsurance).string()) diff --git a/migration/src/m20230114_114628_create_application.rs b/migration/src/m20230114_114628_create_application.rs index 48330ab..004dbd3 100644 --- a/migration/src/m20230114_114628_create_application.rs +++ b/migration/src/m20230114_114628_create_application.rs @@ -26,7 +26,17 @@ impl MigrationTrait for Migration { .col(ColumnDef::new(Application::UpdatedAt).date_time().not_null()) .to_owned(), ) - .await + .await?; + + manager.create_index( + Index::create() + .name("idx_application_candidate_id") + .table(Application::Table) + .col(Application::CandidateId) + .to_owned(), + ).await?; + + Ok(()) } async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {