MM-43045: minimize JOIN Posts (#19934)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
348602cf00
Коммит
5bd223c836
@@ -2491,13 +2491,12 @@ func TestCollapsedThreadFetch(t *testing.T) {
|
||||
}()
|
||||
|
||||
require.NotPanics(t, func() {
|
||||
_, err = th.App.CreatePost(th.Context, &model.Post{
|
||||
th.App.CreatePost(th.Context, &model.Post{
|
||||
UserId: user1.Id,
|
||||
ChannelId: channel.Id,
|
||||
RootId: postRoot.Id,
|
||||
Message: fmt.Sprintf("@%s", user2.Username),
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err)
|
||||
})
|
||||
|
||||
wg.Wait()
|
||||
|
||||
25
app/user.go
25
app/user.go
@@ -2311,15 +2311,20 @@ func (a *App) GetThreadsForUser(userID, teamID string, options model.GetUserThre
|
||||
return nil
|
||||
})
|
||||
|
||||
eg.Go(func() error {
|
||||
totalCount, err := a.Srv().Store.Thread().GetTotalThreads(userID, teamID, options)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to count threads for user id=%s", userID)
|
||||
}
|
||||
result.Total = totalCount
|
||||
// Unread is a legacy flag that caused GetTotalThreads to compute the same value as
|
||||
// GetTotalUnreadThreads. If unspecified, do this work normally; otherwise, skip,
|
||||
// and send back duplicate values down below.
|
||||
if !options.Unread {
|
||||
eg.Go(func() error {
|
||||
totalCount, err := a.Srv().Store.Thread().GetTotalThreads(userID, teamID, options)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to count threads for user id=%s", userID)
|
||||
}
|
||||
result.Total = totalCount
|
||||
|
||||
return nil
|
||||
})
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
eg.Go(func() error {
|
||||
totalUnreadMentions, err := a.Srv().Store.Thread().GetTotalUnreadMentions(userID, teamID, options)
|
||||
@@ -2348,6 +2353,10 @@ func (a *App) GetThreadsForUser(userID, teamID string, options model.GetUserThre
|
||||
return nil, model.NewAppError("GetThreadsForUser", "app.user.get_threads_for_user.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if options.Unread {
|
||||
result.Total = result.TotalUnreadThreads
|
||||
}
|
||||
|
||||
for _, thread := range result.Threads {
|
||||
a.sanitizeProfiles(thread.Participants, false)
|
||||
thread.Post.SanitizeProps()
|
||||
|
||||
Ссылка в новой задаче
Block a user