fix search sql for posts without any comment
This commit is contained in:
@@ -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(" ", "%"));
|
||||
|
||||
@@ -65,7 +65,7 @@ impl PostCache {
|
||||
pub async fn get(&mut self) -> Option<Post> {
|
||||
let rds_result = self.rconn.get::<&String, String>(&self.key).await;
|
||||
if let Ok(s) = rds_result {
|
||||
debug!("hint post cache: {}", &s);
|
||||
debug!("hint post cache");
|
||||
self.rconn
|
||||
.expire::<&String, bool>(&self.key, INSTANCE_EXPIRE_TIME)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user