MM-11434 Performance improvements for post metadata (#9849)
* Remove unused error return value from PreparePostForClient * Remove unused error return value from PreparePostListForClient * MM-11434 Parallelize PreparePostListForClient * MM-11434 Skip looking reactions and files on post whenever possible * Add note about the use of deprecated fields
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7aef759fd8
Коммит
23c8950312
@@ -488,10 +488,7 @@ func getPinnedPosts(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
clientPostList, err := c.App.PreparePostListForClient(posts)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to prepare posts for getFlaggedPostsForUser response", mlog.Any("err", err))
|
||||
}
|
||||
clientPostList := c.App.PreparePostListForClient(posts)
|
||||
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, clientPostList.Etag())
|
||||
w.Write([]byte(clientPostList.ToJson()))
|
||||
|
||||
54
api4/post.go
54
api4/post.go
@@ -9,7 +9,6 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/mlog"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
)
|
||||
|
||||
@@ -68,13 +67,8 @@ func createPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.App.SetStatusOnline(c.Session.UserId, false)
|
||||
c.App.UpdateLastActivityAtIfNeeded(c.Session)
|
||||
|
||||
clientPost, err := c.App.PreparePostForClient(rp)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to prepare post for createPost response", mlog.Any("err", err))
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
w.Write([]byte(clientPost.ToJson()))
|
||||
w.Write([]byte(c.App.PreparePostForClient(rp).ToJson()))
|
||||
}
|
||||
|
||||
func createEphemeralPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
@@ -101,13 +95,8 @@ func createEphemeralPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
rp := c.App.SendEphemeralPost(ephRequest.UserID, c.App.PostWithProxyRemovedFromImageURLs(ephRequest.Post))
|
||||
|
||||
clientPost, err := c.App.PreparePostForClient(rp)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to prepare post for createEphemeralPost response", mlog.Any("err", err))
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
w.Write([]byte(clientPost.ToJson()))
|
||||
w.Write([]byte(c.App.PreparePostForClient(rp).ToJson()))
|
||||
}
|
||||
|
||||
func getPostsForChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
@@ -177,12 +166,7 @@ func getPostsForChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, etag)
|
||||
}
|
||||
|
||||
clientPostList, err := c.App.PreparePostListForClient(list)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to prepare posts for getPostsForChannel response", mlog.Any("err", err))
|
||||
}
|
||||
|
||||
w.Write([]byte(clientPostList.ToJson()))
|
||||
w.Write([]byte(c.App.PreparePostListForClient(list).ToJson()))
|
||||
}
|
||||
|
||||
func getFlaggedPostsForUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
@@ -215,12 +199,7 @@ func getFlaggedPostsForUser(c *Context, w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
clientPostList, err := c.App.PreparePostListForClient(posts)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to prepare posts for getFlaggedPostsForUser response", mlog.Any("err", err))
|
||||
}
|
||||
|
||||
w.Write([]byte(clientPostList.ToJson()))
|
||||
w.Write([]byte(c.App.PreparePostListForClient(posts).ToJson()))
|
||||
}
|
||||
|
||||
func getPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
@@ -254,10 +233,7 @@ func getPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
post, err = c.App.PreparePostForClient(post)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to prepare post for getPost response", mlog.Any("err", err))
|
||||
}
|
||||
post = c.App.PreparePostForClient(post)
|
||||
|
||||
if c.HandleEtag(post.Etag(), "Get Post", w, r) {
|
||||
return
|
||||
@@ -342,10 +318,7 @@ func getPostThread(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
clientPostList, err := c.App.PreparePostListForClient(list)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to prepare posts for getFlaggedPostsForUser response", mlog.Any("err", err))
|
||||
}
|
||||
clientPostList := c.App.PreparePostListForClient(list)
|
||||
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, clientPostList.Etag())
|
||||
|
||||
@@ -412,10 +385,7 @@ func searchPosts(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
clientPostList, err := c.App.PreparePostListForClient(results.PostList)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to prepare posts for searchPosts response", mlog.Any("err", err))
|
||||
}
|
||||
clientPostList := c.App.PreparePostListForClient(results.PostList)
|
||||
|
||||
results = model.MakePostSearchResults(clientPostList, results.Matches)
|
||||
|
||||
@@ -468,10 +438,7 @@ func updatePost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
rpost, err = c.App.PreparePostForClient(rpost)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to prepare post for updatePost response", mlog.Any("err", err))
|
||||
}
|
||||
rpost = c.App.PreparePostForClient(rpost)
|
||||
|
||||
w.Write([]byte(rpost.ToJson()))
|
||||
}
|
||||
@@ -513,10 +480,7 @@ func patchPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
patchedPost, err = c.App.PreparePostForClient(patchedPost)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to prepare post for patchPost response", mlog.Any("err", err))
|
||||
}
|
||||
patchedPost = c.App.PreparePostForClient(patchedPost)
|
||||
|
||||
w.Write([]byte(patchedPost.ToJson()))
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user