delete get/list/list_by_owner channels, get_settings/activity_log admin, get_item/get_sync_status/list_collections/list_seasons/list_shows/list_genres library, get/list/delete providers, get/list/patch_label config_snapshots, get_active/list_history/delete_after schedule — all single-delegation. remove ChannelQueryDeps, LibraryQueryDeps, deleted query/command structs. add direct port fields to AppState. update MCP crate accordingly.
54 lines
1.4 KiB
Rust
54 lines
1.4 KiB
Rust
use domain::DomainResult;
|
|
use domain::models::MediaItem;
|
|
use domain::value_objects::LibrarySearchFilter;
|
|
|
|
use super::deps::LibraryCommandDeps;
|
|
use super::parse_content_type;
|
|
use super::queries::SearchItemsQuery;
|
|
|
|
pub async fn execute(
|
|
deps: &LibraryCommandDeps,
|
|
query: SearchItemsQuery,
|
|
) -> DomainResult<(Vec<MediaItem>, u32)> {
|
|
let content_type = query
|
|
.content_type
|
|
.as_deref()
|
|
.map(parse_content_type)
|
|
.transpose()?;
|
|
|
|
let mut filter = LibrarySearchFilter::new()
|
|
.with_offset(query.offset)
|
|
.with_limit(query.limit);
|
|
|
|
if let Some(pid) = query.provider_id {
|
|
filter = filter.with_provider_id(pid);
|
|
}
|
|
if let Some(ct) = content_type {
|
|
filter = filter.with_content_type(ct);
|
|
}
|
|
if !query.genres.is_empty() {
|
|
filter = filter.with_genres(query.genres);
|
|
}
|
|
if let Some(term) = query.search_term {
|
|
filter = filter.with_search_term(term);
|
|
}
|
|
if let Some(cid) = query.collection_id {
|
|
filter = filter.with_collection_id(cid);
|
|
}
|
|
if !query.series_names.is_empty() {
|
|
filter = filter.with_series_names(query.series_names);
|
|
}
|
|
if let Some(sn) = query.season_number {
|
|
filter = filter.with_season_number(sn);
|
|
}
|
|
if let Some(decade) = query.decade {
|
|
filter = filter.with_decade(decade);
|
|
}
|
|
|
|
deps.library_query.search(&filter).await
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "tests/search.rs"]
|
|
mod tests;
|