refactor(application): strip comments, DRY ownership check + parse_content_type
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
use domain::errors::{DomainError, DomainResult};
|
||||
use domain::DomainResult;
|
||||
use domain::models::LibraryItem;
|
||||
use domain::value_objects::{ContentType, LibrarySearchFilter};
|
||||
use domain::value_objects::LibrarySearchFilter;
|
||||
|
||||
use super::deps::LibraryQueryDeps;
|
||||
use super::parse_content_type;
|
||||
use super::queries::SearchItemsQuery;
|
||||
|
||||
/// Search library items with filters. Returns `(items, total_count)`.
|
||||
pub async fn execute(
|
||||
deps: &LibraryQueryDeps,
|
||||
query: SearchItemsQuery,
|
||||
@@ -48,17 +48,6 @@ pub async fn execute(
|
||||
deps.library_query.search(&filter).await
|
||||
}
|
||||
|
||||
fn parse_content_type(s: &str) -> DomainResult<ContentType> {
|
||||
match s {
|
||||
"movie" => Ok(ContentType::Movie),
|
||||
"episode" => Ok(ContentType::Episode),
|
||||
"short" => Ok(ContentType::Short),
|
||||
other => Err(DomainError::ValidationError(format!(
|
||||
"Unknown content type '{other}'. Use movie, episode, or short."
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tests/search.rs"]
|
||||
mod tests;
|
||||
|
||||
Reference in New Issue
Block a user