diff options
author | Chris <ccbrown112@gmail.com> | 2017-10-09 10:16:14 -0700 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-10-09 13:16:14 -0400 |
commit | 0f66b6e72621842467d0e368b95ee58f485d4ace (patch) | |
tree | 444f9210a151cb735fe0502d4bb47c324592c0e6 /store/sqlstore/post_store.go | |
parent | 70e5f00241473c27a3008959ce08832c75e76ba8 (diff) | |
download | chat-0f66b6e72621842467d0e368b95ee58f485d4ace.tar.gz chat-0f66b6e72621842467d0e368b95ee58f485d4ace.tar.bz2 chat-0f66b6e72621842467d0e368b95ee58f485d4ace.zip |
store/sqlstore cleanup and postgres tests (#7595)
* sqlstore cleanup / postgres tests
* remove stopped containers
* cmd/platform compile fix
* remove test-postgres target from makefile
Diffstat (limited to 'store/sqlstore/post_store.go')
-rw-r--r-- | store/sqlstore/post_store.go | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/store/sqlstore/post_store.go b/store/sqlstore/post_store.go index 53af44ca1..a1b25b5c5 100644 --- a/store/sqlstore/post_store.go +++ b/store/sqlstore/post_store.go @@ -713,14 +713,6 @@ var specialSearchChar = []string{ func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchParams) store.StoreChannel { return store.Do(func(result *store.StoreResult) { - if !*utils.Cfg.ServiceSettings.EnablePostSearch { - list := model.NewPostList() - result.Data = list - - result.Err = model.NewAppError("SqlPostStore.Search", "store.sql_post.search.disabled", nil, fmt.Sprintf("teamId=%v userId=%v params=%v", teamId, userId, params.ToJson()), http.StatusNotImplemented) - return - } - queryParams := map[string]interface{}{ "TeamId": teamId, "UserId": userId, @@ -833,7 +825,7 @@ func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchP if terms == "" { // we've already confirmed that we have a channel or user to search for searchQuery = strings.Replace(searchQuery, "SEARCH_CLAUSE", "", 1) - } else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES { + } else if s.DriverName() == model.DATABASE_DRIVER_POSTGRES { // Parse text for wildcards if wildcard, err := regexp.Compile("\\*($| )"); err == nil { terms = wildcard.ReplaceAllLiteralString(terms, ":* ") @@ -847,7 +839,7 @@ func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchP searchClause := fmt.Sprintf("AND %s @@ to_tsquery(:Terms)", searchType) searchQuery = strings.Replace(searchQuery, "SEARCH_CLAUSE", searchClause, 1) - } else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL { + } else if s.DriverName() == model.DATABASE_DRIVER_MYSQL { searchClause := fmt.Sprintf("AND MATCH (%s) AGAINST (:Terms IN BOOLEAN MODE)", searchType) searchQuery = strings.Replace(searchQuery, "SEARCH_CLAUSE", searchClause, 1) @@ -912,7 +904,7 @@ func (s SqlPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) store.Sto ORDER BY Name DESC LIMIT 30` - if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES { + if s.DriverName() == model.DATABASE_DRIVER_POSTGRES { query = `SELECT TO_CHAR(DATE(TO_TIMESTAMP(Posts.CreateAt / 1000)), 'YYYY-MM-DD') AS Name, COUNT(DISTINCT Posts.UserId) AS Value @@ -966,7 +958,7 @@ func (s SqlPostStore) AnalyticsPostCountsByDay(teamId string) store.StoreChannel ORDER BY Name DESC LIMIT 30` - if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES { + if s.DriverName() == model.DATABASE_DRIVER_POSTGRES { query = `SELECT TO_CHAR(DATE(TO_TIMESTAMP(Posts.CreateAt / 1000)), 'YYYY-MM-DD') AS Name, Count(Posts.Id) AS Value @@ -1110,7 +1102,7 @@ func (s SqlPostStore) GetPostsBatchForIndexing(startTime int64, limit int) store func (s SqlPostStore) PermanentDeleteBatch(endTime int64, limit int64) store.StoreChannel { return store.Do(func(result *store.StoreResult) { var query string - if *utils.Cfg.SqlSettings.DriverName == "postgres" { + if s.DriverName() == "postgres" { query = "DELETE from Posts WHERE Id = any (array (SELECT Id FROM Posts WHERE CreateAt < :EndTime LIMIT :Limit))" } else { query = "DELETE from Posts WHERE CreateAt < :EndTime LIMIT :Limit" |