eliminate multiple calls to counter in paginated user comments

This commit is contained in:
Umputun
2018-06-01 22:51:19 -05:00
parent 837b2ef719
commit afbddaa5ec
6 changed files with 70 additions and 38 deletions
+6 -1
View File
@@ -444,11 +444,16 @@ func (s *Rest) findUserCommentsCtrl(w http.ResponseWriter, r *http.Request) {
log.Printf("[DEBUG] get comments for userID %s, %s", userID, siteID)
data, err := s.Cache.Get(cache.Key(cache.URLKey(r), userID, siteID), func() ([]byte, error) {
comments, count, e := s.DataService.User(siteID, userID, limit, 0)
comments, e := s.DataService.User(siteID, userID, limit, 0)
if e != nil {
return nil, e
}
comments = s.adminService.alterComments(comments, r)
count, e := s.DataService.UserCount(siteID, userID)
if e != nil {
return nil, e
}
resp.Comments, resp.Count = comments, count
return encodeJSONWithHTML(resp)
})