Filter script kinds in the backend (#2450)

This commit is contained in:
Guillaume Bouvignies
2023-10-13 20:34:39 +02:00
committed by GitHub
parent ad75e78228
commit bcdff7d6f1
8 changed files with 18 additions and 22 deletions
+9 -2
View File
@@ -218,8 +218,15 @@ async fn list_scripts(
if let Some(it) = &lq.is_template {
sqlb.and_where_eq("is_template", it);
}
if let Some(k) = &lq.kind {
sqlb.and_where_eq("kind", "?".bind(&k.to_lowercase()));
if let Some(kinds_val) = &lq.kinds {
let lowercased_kinds: Vec<String> = kinds_val
.split(",")
.map(&str::to_lowercase)
.map(sql_builder::quote)
.collect();
if lowercased_kinds.len() > 0 {
sqlb.and_where_in("kind", lowercased_kinds.as_slice());
}
}
if lq.starred_only.unwrap_or(false) {
sqlb.and_where_is_not_null("favorite.path");