Skip to content

Commit

Permalink
Also search url field by default (#5459)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic authored Feb 28, 2025
1 parent 1a299ba commit 6e3355f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/db_views/src/post/post_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,9 @@ impl<'a> PostQuery<'a> {
}

if let Some(search_term) = &o.search_term {
let url_filter = post::url.eq(search_term);
if o.url_only.unwrap_or_default() {
query = query.filter(post::url.eq(search_term));
query = query.filter(url_filter);
} else {
let searcher = fuzzy_search(search_term);
let name_filter = post::name.ilike(searcher.clone());
Expand All @@ -493,7 +494,12 @@ impl<'a> PostQuery<'a> {
query = if o.title_only.unwrap_or_default() {
query.filter(name_filter)
} else {
query.filter(name_filter.or(body_filter).or(alt_text_filter))
query.filter(
name_filter
.or(body_filter)
.or(alt_text_filter)
.or(url_filter),
)
}
.filter(not(post::removed.or(post::deleted)));
}
Expand Down

0 comments on commit 6e3355f

Please sign in to comment.