Adds elasticsearch to the user and channel autocompletion functions (#10354)

* Adds elasticsearch to the user and channel autocompletion functions

* Implement channel store GetChannelsByIds test

* Style changes and govet fixes

* Add gofmt fixes

* Extract default channel search limit to a const

* Add StringSliceDiff function to the utils package

* Honor USER_SEARCH_MAX_LIMIT on the user autocomplete api handler

* Change the elasticsearch development image
Этот коммит содержится в:
Miguel de la Cruz
2019-03-15 17:53:53 +00:00
коммит произвёл GitHub
родитель 5dae08761c
Коммит 44887a0272
17 изменённых файлов: 461 добавлений и 13 удалений

Просмотреть файл

@@ -785,10 +785,10 @@ func (s SqlChannelStore) SetDeleteAt(channelId string, deleteAt, updateAt int64)
// Additionally propagate the write to the PublicChannels table.
if _, err := transaction.Exec(`
UPDATE
PublicChannels
SET
PublicChannels
SET
DeleteAt = :DeleteAt
WHERE
WHERE
Id = :ChannelId
`, map[string]interface{}{
"DeleteAt": deleteAt,
@@ -835,7 +835,7 @@ func (s SqlChannelStore) PermanentDeleteByTeam(teamId string) store.StoreChannel
// Additionally propagate the deletions to the PublicChannels table.
if _, err := transaction.Exec(`
DELETE FROM
PublicChannels
PublicChannels
WHERE
TeamId = :TeamId
`, map[string]interface{}{
@@ -881,7 +881,7 @@ func (s SqlChannelStore) PermanentDelete(channelId string) store.StoreChannel {
// Additionally propagate the deletion to the PublicChannels table.
if _, err := transaction.Exec(`
DELETE FROM
PublicChannels
PublicChannels
WHERE
Id = :ChannelId
`, map[string]interface{}{
@@ -1689,7 +1689,7 @@ func (s SqlChannelStore) RemoveAllDeactivatedMembers(channelId string) store.Sto
DELETE
FROM
ChannelMembers
WHERE
WHERE
UserId IN (
SELECT
Id
@@ -1838,6 +1838,24 @@ func (s SqlChannelStore) GetAll(teamId string) store.StoreChannel {
})
}
func (s SqlChannelStore) GetChannelsByIds(channelIds []string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
keys, params := MapStringsToQueryParams(channelIds, "Channel")
query := `SELECT * FROM Channels WHERE Id IN ` + keys + ` ORDER BY Name`
var channels []*model.Channel
_, err := s.GetReplica().Select(&channels, query, params)
if err != nil {
mlog.Error(fmt.Sprint(err))
result.Err = model.NewAppError("SqlChannelStore.GetChannelsByIds", "store.sql_channel.get_channels_by_ids.app_error", nil, "", http.StatusInternalServerError)
} else {
result.Data = channels
}
})
}
func (s SqlChannelStore) GetForPost(postId string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
channel := &model.Channel{}
@@ -1942,8 +1960,7 @@ func (s SqlChannelStore) AutocompleteInTeam(teamId string, term string, includeD
c.TeamId = :TeamId
` + deleteFilter + `
%v
LIMIT 50
`
LIMIT ` + strconv.Itoa(model.CHANNEL_SEARCH_DEFAULT_LIMIT)
var channels model.ChannelList