From a8d116b381ec9c28c5da5c8ee39a3699f568130d Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 10 Sep 2018 06:20:01 -0700 Subject: Speed up search results post selection. (#9380) --- app/post.go | 6 ++++-- store/sqlstore/post_store.go | 2 +- store/storetest/post_store.go | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/post.go b/app/post.go index 30602b392..8cfc6d659 100644 --- a/app/post.go +++ b/app/post.go @@ -705,8 +705,10 @@ func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOr return nil, presult.Err } else { for _, p := range presult.Data.([]*model.Post) { - postList.AddPost(p) - postList.AddOrder(p.Id) + if p.DeleteAt == 0 { + postList.AddPost(p) + postList.AddOrder(p.Id) + } } } } diff --git a/store/sqlstore/post_store.go b/store/sqlstore/post_store.go index 14a6039bc..9cf33888d 100644 --- a/store/sqlstore/post_store.go +++ b/store/sqlstore/post_store.go @@ -1156,7 +1156,7 @@ func (s *SqlPostStore) GetPostsByIds(postIds []string) store.StoreChannel { params[key] = postId } - query := `SELECT * FROM Posts WHERE Id in (` + keys.String() + `) and DeleteAt = 0 ORDER BY CreateAt DESC` + query := `SELECT * FROM Posts WHERE Id in (` + keys.String() + `) ORDER BY CreateAt DESC` var posts []*model.Post _, err := s.GetReplica().Select(&posts, query, params) diff --git a/store/storetest/post_store.go b/store/storetest/post_store.go index b3a7e8d12..235d6f9b7 100644 --- a/store/storetest/post_store.go +++ b/store/storetest/post_store.go @@ -1674,8 +1674,8 @@ func testPostStoreGetPostsByIds(t *testing.T, ss store.Store) { store.Must(ss.Post().Delete(ro1.Id, model.GetMillis(), "")) - if ro5 := store.Must(ss.Post().GetPostsByIds(postIds)).([]*model.Post); len(ro5) != 2 { - t.Fatalf("Expected 2 posts in results. Got %v", len(ro5)) + if ro5 := store.Must(ss.Post().GetPostsByIds(postIds)).([]*model.Post); len(ro5) != 3 { + t.Fatalf("Expected 3 posts in results. Got %v", len(ro5)) } } -- cgit v1.2.3-1-g7c22