[MM-15854] Migrate "Post.Search" to Sync by default (#11002)
* Migrate Post.Search to Sync by default * app/post.go channels modification * Removing tabs * Removing tabs * Reverting GetEtag modification * Fixing channel corruption error * Adding Done signal for goroutines * remove fixed length wg * undo wg short declaration * Removing one comment * Fixing change * Fixing store mocks * Fixing typo
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
0b90888e73
Коммит
89d8dd6816
20
app/post.go
20
app/post.go
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/mlog"
|
||||
@@ -895,7 +896,9 @@ func (a *App) parseAndFetchChannelIdByNameFromInFilter(channelName, userId, team
|
||||
}
|
||||
|
||||
func (a *App) searchPostsInTeam(teamId string, userId string, paramsList []*model.SearchParams, modifierFun func(*model.SearchParams)) (*model.PostList, *model.AppError) {
|
||||
channels := []store.StoreChannel{}
|
||||
var wg sync.WaitGroup
|
||||
|
||||
pchan := make(chan store.StoreResult, len(paramsList))
|
||||
|
||||
for _, params := range paramsList {
|
||||
// Don't allow users to search for everything.
|
||||
@@ -903,12 +906,21 @@ func (a *App) searchPostsInTeam(teamId string, userId string, paramsList []*mode
|
||||
continue
|
||||
}
|
||||
modifierFun(params)
|
||||
channels = append(channels, a.Srv.Store.Post().Search(teamId, userId, params))
|
||||
wg.Add(1)
|
||||
|
||||
go func(params *model.SearchParams) {
|
||||
defer wg.Done()
|
||||
postList, err := a.Srv.Store.Post().Search(teamId, userId, params)
|
||||
pchan <- store.StoreResult{Data: postList, Err: err}
|
||||
}(params)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
close(pchan)
|
||||
|
||||
posts := model.NewPostList()
|
||||
for _, channel := range channels {
|
||||
result := <-channel
|
||||
|
||||
for result := range pchan {
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user