mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-18 05:51:17 +00:00
feat(candidate list): get submission progress, fix paging
This commit is contained in:
parent
41dd84b22d
commit
b1eb81d00b
4 changed files with 17 additions and 12 deletions
|
|
@ -50,13 +50,15 @@ impl Query {
|
|||
select
|
||||
}
|
||||
.order_by(candidate::Column::Application, Order::Asc)
|
||||
.into_model::<CandidateResult>()
|
||||
.paginate(db, PAGE_SIZE);
|
||||
.into_model::<CandidateResult>();
|
||||
|
||||
if let Some(page) = page {
|
||||
query.fetch_page(page).await
|
||||
query
|
||||
.paginate(db, PAGE_SIZE)
|
||||
.fetch_page(page).await
|
||||
} else {
|
||||
query.fetch().await
|
||||
query
|
||||
.all(db).await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use chrono::NaiveDate;
|
|||
use sea_orm::FromQueryResult;
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use crate::{error::ServiceError, database::query::candidate::CandidateResult};
|
||||
use crate::{error::ServiceError, database::query::candidate::CandidateResult, services::portfolio_service::SubmissionProgress};
|
||||
|
||||
use super::candidate_details::decrypt_if_exists;
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ pub struct BaseCandidateResponse {
|
|||
pub email: String,
|
||||
pub telephone: String,
|
||||
pub study: String,
|
||||
pub submitted: bool,
|
||||
pub progress: SubmissionProgress,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
|
||||
|
|
@ -94,12 +94,13 @@ impl BaseCandidateResponse {
|
|||
pub async fn from_encrypted(
|
||||
private_key: &String,
|
||||
c: CandidateResult,
|
||||
submitted: bool,
|
||||
progress: Option<SubmissionProgress>,
|
||||
) -> Result<Self, ServiceError> {
|
||||
let name = decrypt_if_exists(private_key, c.name).await?;
|
||||
let surname = decrypt_if_exists(private_key, c.surname).await?;
|
||||
let email = decrypt_if_exists(private_key, c.email).await?;
|
||||
let telephone = decrypt_if_exists(private_key, c.telephone).await?;
|
||||
let progress = progress.unwrap_or(SubmissionProgress::NoneInCache);
|
||||
Ok(
|
||||
Self {
|
||||
application_id: c.application,
|
||||
|
|
@ -108,7 +109,7 @@ impl BaseCandidateResponse {
|
|||
email,
|
||||
telephone,
|
||||
study: c.study.unwrap_or("".to_string()),
|
||||
submitted,
|
||||
progress,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,9 +178,10 @@ impl CandidateService {
|
|||
.iter()
|
||||
.map(|c| async move {
|
||||
BaseCandidateResponse::from_encrypted(
|
||||
private_key,
|
||||
c.clone(),
|
||||
true).await
|
||||
private_key,
|
||||
c.clone(),
|
||||
PortfolioService::get_submission_progress(c.application).await.ok()
|
||||
).await
|
||||
})
|
||||
).await
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
|||
|
||||
use crate::{error::ServiceError, Query, crypto};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum SubmissionProgress {
|
||||
NoneInCache,
|
||||
SomeInCache(Vec<FileType>),
|
||||
|
|
@ -49,7 +50,7 @@ impl Serialize for SubmissionProgress {
|
|||
}
|
||||
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum FileType {
|
||||
CoverLetterPdf = 1,
|
||||
PortfolioLetterPdf = 2,
|
||||
|
|
|
|||
Loading…
Reference in a new issue