[MM-44434] Introduced search for channel id's through system console. (#20259)
* Introduced search for channel id's * Small fix to test case as it is not looking at count * Introduced searching channels by id as a ChannelOpt. Defaulting to true for system console for the time being * go fmt * Modified whether to include search by id by passing it in as prop to search endpoint. Modified webapp to pass through search by id as well * Fixed issue with full text search, as there is not always necessarily an index on Id. * Modified test to verify count, and moved code inside conditional Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f15873eaf4
Коммит
dd7067cbe9
@@ -3292,14 +3292,26 @@ func (s SqlChannelStore) channelSearchQuery(opts *store.ChannelSearchOpts) sq.Se
|
||||
LeftJoin("RetentionPoliciesChannels ON c.Id = RetentionPoliciesChannels.ChannelId")
|
||||
}
|
||||
|
||||
likeClause, likeTerm := s.buildLIKEClause(opts.Term, "c.Name, c.DisplayName, c.Purpose")
|
||||
likeFields := "c.Name, c.DisplayName, c.Purpose"
|
||||
if opts.IncludeSearchById {
|
||||
likeFields = likeFields + ", c.Id"
|
||||
}
|
||||
|
||||
likeClause, likeTerm := s.buildLIKEClause(opts.Term, likeFields)
|
||||
|
||||
if likeTerm != "" {
|
||||
// Keep the number of likeTerms same as the number of columns
|
||||
// (c.Name, c.DisplayName, c.Purpose, c.Id?)
|
||||
likeTerms := make([]interface{}, len(strings.Split(likeFields, ",")))
|
||||
for i := 0; i < len(likeTerms); i++ {
|
||||
likeTerms[i] = likeTerm
|
||||
}
|
||||
likeClause = strings.ReplaceAll(likeClause, ":LikeTerm", "?")
|
||||
fulltextClause, fulltextTerm := s.buildFulltextClause(opts.Term, "c.Name, c.DisplayName, c.Purpose")
|
||||
fulltextClause = strings.ReplaceAll(fulltextClause, ":FulltextTerm", "?")
|
||||
|
||||
query = query.Where(sq.Or{
|
||||
sq.Expr(likeClause, likeTerm, likeTerm, likeTerm), // Keep the number of likeTerms same as the number
|
||||
// of columns (c.Name, c.DisplayName, c.Purpose)
|
||||
sq.Expr(likeClause, likeTerms...),
|
||||
sq.Expr(fulltextClause, fulltextTerm),
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user