Increase performance when receiving posts in 3.6 (#5385)

This commit is contained in:
Joram Wilander
2017-02-16 19:09:08 +00:00
committed by George Goldberg
parent c5458f1609
commit 22bb594a2b
17 changed files with 206 additions and 60 deletions
+9 -9
View File
@@ -1257,12 +1257,11 @@ func viewChannel(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if len(view.ChannelId) == 0 {
ReturnStatusOK(w)
return
}
channelIds := []string{}
channelIds := []string{view.ChannelId}
if len(view.ChannelId) > 0 {
channelIds = append(channelIds, view.ChannelId)
}
var pchan store.StoreChannel
if len(view.PrevChannelId) > 0 {
@@ -1273,6 +1272,11 @@ func viewChannel(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
if len(channelIds) == 0 {
ReturnStatusOK(w)
return
}
uchan := Srv.Store.Channel().UpdateLastViewedAt(channelIds, c.Session.UserId)
if pchan != nil {
@@ -1291,10 +1295,6 @@ func viewChannel(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_VIEWED, c.TeamId, "", c.Session.UserId, nil)
message.Add("channel_id", view.ChannelId)
go Publish(message)
ReturnStatusOK(w)
}
-10
View File
@@ -99,11 +99,6 @@ func updateLastViewedAt(c *Context, w http.ResponseWriter, r *http.Request) {
Srv.Store.Preference().Save(&model.Preferences{teamPref, chanPref})
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_VIEWED, c.TeamId, "", c.Session.UserId, nil)
message.Add("channel_id", id)
go Publish(message)
result := make(map[string]string)
result["id"] = id
w.Write([]byte(model.MapToJson(result)))
@@ -134,11 +129,6 @@ func setLastViewedAt(c *Context, w http.ResponseWriter, r *http.Request) {
Srv.Store.Preference().Save(&model.Preferences{teamPref, chanPref})
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_VIEWED, c.TeamId, "", c.Session.UserId, nil)
message.Add("channel_id", id)
go Publish(message)
result := make(map[string]string)
result["id"] = id
w.Write([]byte(model.MapToJson(result)))