fix search sql for posts without any comment

This commit is contained in:
2022-03-23 23:15:48 +08:00
parent ce21b2825e
commit cb1ebfeb56
2 changed files with 3 additions and 4 deletions

View File

@@ -177,8 +177,7 @@ impl Post {
let pat;
let mut query = base_query!(posts)
.distinct()
.left_join(comments::table)
.filter(comments::is_deleted.eq(false));
.left_join(comments::table);
// 先用搜索+缓存性能有问题了再真的做tag表
query = match search_mode {
0 => {
@@ -187,7 +186,7 @@ impl Post {
.filter(posts::cw.eq(&search_text))
.or_filter(posts::cw.eq(format!("#{}", &search_text)))
.or_filter(posts::content.like(&pat))
.or_filter(comments::content.like(&pat))
.or_filter(comments::content.like(&pat).and(comments::is_deleted.eq(false)))
}
1 => {
pat = format!("%{}%", search_text2.replace(" ", "%"));