mirror of
https://github.com/danbulant/Portfolio
synced 2026-07-04 02:20:50 +00:00
feat: use seperate functions
This commit is contained in:
parent
e360983d88
commit
b31b557ae0
2 changed files with 28 additions and 19 deletions
|
|
@ -128,12 +128,9 @@ pub async fn upload_cover_letter(
|
||||||
pub async fn delete_cover_letter(session: CandidateAuth) -> Result<(), Custom<String>> {
|
pub async fn delete_cover_letter(session: CandidateAuth) -> Result<(), Custom<String>> {
|
||||||
let candidate: entity::candidate::Model = session.into();
|
let candidate: entity::candidate::Model = session.into();
|
||||||
|
|
||||||
PortfolioService::delete_cache_item(
|
PortfolioService::delete_cover_letter_from_cache(candidate.application)
|
||||||
candidate.application,
|
.await
|
||||||
portfolio_core::services::portfolio_service::FileType::CoverLetterPdf,
|
.map_err(to_custom_error)?;
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map_err(to_custom_error)?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -156,12 +153,9 @@ pub async fn upload_portfolio_letter(
|
||||||
pub async fn delete_portfolio_letter(session: CandidateAuth) -> Result<(), Custom<String>> {
|
pub async fn delete_portfolio_letter(session: CandidateAuth) -> Result<(), Custom<String>> {
|
||||||
let candidate: entity::candidate::Model = session.into();
|
let candidate: entity::candidate::Model = session.into();
|
||||||
|
|
||||||
PortfolioService::delete_cache_item(
|
PortfolioService::delete_portfolio_letter_from_cache(candidate.application)
|
||||||
candidate.application,
|
.await
|
||||||
portfolio_core::services::portfolio_service::FileType::PortfolioLetterPdf,
|
.map_err(to_custom_error)?;
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map_err(to_custom_error)?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -184,12 +178,9 @@ pub async fn upload_portfolio_zip(
|
||||||
pub async fn delete_portfolio_zip(session: CandidateAuth) -> Result<(), Custom<String>> {
|
pub async fn delete_portfolio_zip(session: CandidateAuth) -> Result<(), Custom<String>> {
|
||||||
let candidate: entity::candidate::Model = session.into();
|
let candidate: entity::candidate::Model = session.into();
|
||||||
|
|
||||||
PortfolioService::delete_cache_item(
|
PortfolioService::delete_portfolio_zip_from_cache(candidate.application)
|
||||||
candidate.application,
|
.await
|
||||||
portfolio_core::services::portfolio_service::FileType::PortfolioZip,
|
.map_err(to_custom_error)?;
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map_err(to_custom_error)?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ impl PortfolioService {
|
||||||
|
|
||||||
|
|
||||||
/// Returns true if portfolio is ready to be moved to the final directory
|
/// Returns true if portfolio is ready to be moved to the final directory
|
||||||
pub async fn is_portfolio_prepared(candidate_id: i32) -> bool {
|
async fn is_portfolio_prepared(candidate_id: i32) -> bool {
|
||||||
let cache_path = Self::get_file_store_path().join(&candidate_id.to_string()).join("cache");
|
let cache_path = Self::get_file_store_path().join(&candidate_id.to_string()).join("cache");
|
||||||
|
|
||||||
let filenames = vec![FileType::CoverLetterPdf, FileType::PortfolioLetterPdf, FileType::PortfolioZip];
|
let filenames = vec![FileType::CoverLetterPdf, FileType::PortfolioLetterPdf, FileType::PortfolioZip];
|
||||||
|
|
@ -233,6 +233,24 @@ impl PortfolioService {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn delete_cover_letter_from_cache(
|
||||||
|
candidate_id: i32,
|
||||||
|
) -> Result<(), ServiceError> {
|
||||||
|
Self::delete_cache_item(candidate_id, FileType::CoverLetterPdf).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn delete_portfolio_letter_from_cache(
|
||||||
|
candidate_id: i32,
|
||||||
|
) -> Result<(), ServiceError> {
|
||||||
|
Self::delete_cache_item(candidate_id, FileType::PortfolioLetterPdf).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn delete_portfolio_zip_from_cache(
|
||||||
|
candidate_id: i32,
|
||||||
|
) -> Result<(), ServiceError> {
|
||||||
|
Self::delete_cache_item(candidate_id, FileType::PortfolioZip).await
|
||||||
|
}
|
||||||
|
|
||||||
/// Removes all files from cache
|
/// Removes all files from cache
|
||||||
pub async fn delete_cache(candidate_id: i32) -> Result<(), ServiceError> {
|
pub async fn delete_cache(candidate_id: i32) -> Result<(), ServiceError> {
|
||||||
let cache_path = Self::get_file_store_path().join(&candidate_id.to_string()).join("cache");
|
let cache_path = Self::get_file_store_path().join(&candidate_id.to_string()).join("cache");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue