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