fix: wire tags filter through LibrarySearchFilter to SQLite adapter
This commit is contained in:
@@ -273,6 +273,19 @@ impl LibraryQuery for SqliteLibraryRepository {
|
|||||||
.collect();
|
.collect();
|
||||||
conditions.push(format!("({})", genre_conditions.join(" OR ")));
|
conditions.push(format!("({})", genre_conditions.join(" OR ")));
|
||||||
}
|
}
|
||||||
|
if !filter.tags().is_empty() {
|
||||||
|
let tag_conditions: Vec<String> = filter
|
||||||
|
.tags()
|
||||||
|
.iter()
|
||||||
|
.map(|t| {
|
||||||
|
format!(
|
||||||
|
"EXISTS (SELECT 1 FROM json_each(library_items.tags) WHERE LOWER(value) = LOWER('{}'))",
|
||||||
|
t.replace('\'', "''")
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
conditions.push(format!("({})", tag_conditions.join(" OR ")));
|
||||||
|
}
|
||||||
if let Some(sn) = filter.season_number() {
|
if let Some(sn) = filter.season_number() {
|
||||||
conditions.push(format!("season_number = {}", sn));
|
conditions.push(format!("season_number = {}", sn));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -702,7 +702,7 @@ fn media_filter_to_library_search(filter: &crate::value_objects::MediaFilter) ->
|
|||||||
lsf = lsf.with_search_term(term.clone());
|
lsf = lsf.with_search_term(term.clone());
|
||||||
}
|
}
|
||||||
if !filter.tags.is_empty() {
|
if !filter.tags.is_empty() {
|
||||||
// tags map to the same concept in the library
|
lsf = lsf.with_tags(filter.tags.clone());
|
||||||
}
|
}
|
||||||
lsf
|
lsf
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ pub struct LibrarySearchFilter {
|
|||||||
min_duration_secs: Option<u32>,
|
min_duration_secs: Option<u32>,
|
||||||
max_duration_secs: Option<u32>,
|
max_duration_secs: Option<u32>,
|
||||||
search_term: Option<String>,
|
search_term: Option<String>,
|
||||||
|
tags: Vec<String>,
|
||||||
season_number: Option<u32>,
|
season_number: Option<u32>,
|
||||||
role: Option<MediaRole>,
|
role: Option<MediaRole>,
|
||||||
offset: u32,
|
offset: u32,
|
||||||
@@ -60,6 +61,10 @@ impl LibrarySearchFilter {
|
|||||||
self.search_term = Some(term.into());
|
self.search_term = Some(term.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
pub fn with_tags(mut self, tags: Vec<String>) -> Self {
|
||||||
|
self.tags = tags;
|
||||||
|
self
|
||||||
|
}
|
||||||
pub fn with_season_number(mut self, n: u32) -> Self {
|
pub fn with_season_number(mut self, n: u32) -> Self {
|
||||||
self.season_number = Some(n);
|
self.season_number = Some(n);
|
||||||
self
|
self
|
||||||
@@ -104,6 +109,9 @@ impl LibrarySearchFilter {
|
|||||||
pub fn search_term(&self) -> Option<&str> {
|
pub fn search_term(&self) -> Option<&str> {
|
||||||
self.search_term.as_deref()
|
self.search_term.as_deref()
|
||||||
}
|
}
|
||||||
|
pub fn tags(&self) -> &[String] {
|
||||||
|
&self.tags
|
||||||
|
}
|
||||||
pub fn season_number(&self) -> Option<u32> {
|
pub fn season_number(&self) -> Option<u32> {
|
||||||
self.season_number
|
self.season_number
|
||||||
}
|
}
|
||||||
@@ -130,6 +138,7 @@ impl Default for LibrarySearchFilter {
|
|||||||
min_duration_secs: None,
|
min_duration_secs: None,
|
||||||
max_duration_secs: None,
|
max_duration_secs: None,
|
||||||
search_term: None,
|
search_term: None,
|
||||||
|
tags: vec![],
|
||||||
season_number: None,
|
season_number: None,
|
||||||
role: None,
|
role: None,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user