Adding post body searching. Fixes #507

This commit is contained in:
Dessalines 2020-02-07 11:17:15 -05:00
parent 68ac96147c
commit 65145b719c

View file

@ -178,7 +178,11 @@ impl<'a> PostQueryBuilder<'a> {
pub fn search_term<T: MaybeOptional<String>>(mut self, search_term: T) -> Self {
use super::post_view::post_mview::dsl::*;
if let Some(search_term) = search_term.get_optional() {
self.query = self.query.filter(name.ilike(fuzzy_search(&search_term)));
let searcher = fuzzy_search(&search_term);
self.query = self
.query
.filter(name.ilike(searcher.to_owned()))
.or_filter(body.ilike(searcher));
}
self
}