optimise away this string for non-admins
optimise away redundant parentID column on ViewForum
This commit is contained in:
parent
b1c9e0d11c
commit
5eaa8c8c89
|
@ -138,9 +138,9 @@ func renderTemplate3(tmplName, hookName string, w http.ResponseWriter, r *http.R
|
||||||
FootHeaders(w, h)
|
FootHeaders(w, h)
|
||||||
if h.Zone != "error" {
|
if h.Zone != "error" {
|
||||||
since := time.Duration(uutils.Nanotime() - h.StartedAt)
|
since := time.Duration(uutils.Nanotime() - h.StartedAt)
|
||||||
//if h.CurrentUser.IsAdmin {
|
if h.CurrentUser.IsAdmin {
|
||||||
h.Elapsed1 = since.String()
|
h.Elapsed1 = since.String()
|
||||||
//}
|
}
|
||||||
co.PerfCounter.Push(since /*, false*/)
|
co.PerfCounter.Push(since /*, false*/)
|
||||||
}
|
}
|
||||||
if c.RunPreRenderHook("pre_render_"+hookName, w, r, &h.CurrentUser, pi) {
|
if c.RunPreRenderHook("pre_render_"+hookName, w, r, &h.CurrentUser, pi) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ var forumStmts ForumStmts
|
||||||
func init() {
|
func init() {
|
||||||
c.DbInits.Add(func(acc *qgen.Accumulator) error {
|
c.DbInits.Add(func(acc *qgen.Accumulator) error {
|
||||||
forumStmts = ForumStmts{
|
forumStmts = ForumStmts{
|
||||||
getTopics: acc.Select("topics").Columns("tid, title, content, createdBy, is_closed, sticky, createdAt, lastReplyAt, lastReplyBy, lastReplyID, parentID, views, postCount, likeCount").Where("parentID=?").Orderby("sticky DESC, lastReplyAt DESC, createdBy DESC").Limit("?,?").Prepare(),
|
getTopics: acc.Select("topics").Columns("tid, title, content, createdBy, is_closed, sticky, createdAt, lastReplyAt, lastReplyBy, lastReplyID, views, postCount, likeCount").Where("parentID=?").Orderby("sticky DESC, lastReplyAt DESC, createdBy DESC").Limit("?,?").Prepare(),
|
||||||
}
|
}
|
||||||
return acc.FirstError()
|
return acc.FirstError()
|
||||||
})
|
})
|
||||||
|
@ -69,11 +69,12 @@ func ViewForum(w http.ResponseWriter, r *http.Request, user c.User, header *c.He
|
||||||
reqUserList := make(map[int]bool)
|
reqUserList := make(map[int]bool)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
t := c.TopicsRow{ID: 0}
|
t := c.TopicsRow{ID: 0}
|
||||||
err := rows.Scan(&t.ID, &t.Title, &t.Content, &t.CreatedBy, &t.IsClosed, &t.Sticky, &t.CreatedAt, &t.LastReplyAt, &t.LastReplyBy, &t.LastReplyID, &t.ParentID, &t.ViewCount, &t.PostCount, &t.LikeCount)
|
err := rows.Scan(&t.ID, &t.Title, &t.Content, &t.CreatedBy, &t.IsClosed, &t.Sticky, &t.CreatedAt, &t.LastReplyAt, &t.LastReplyBy, &t.LastReplyID, &t.ViewCount, &t.PostCount, &t.LikeCount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.InternalError(err, w, r)
|
return c.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t.ParentID = fid
|
||||||
t.Link = c.BuildTopicURL(c.NameToSlug(t.Title), t.ID)
|
t.Link = c.BuildTopicURL(c.NameToSlug(t.Title), t.ID)
|
||||||
// TODO: Create a specialised function with a bit less overhead for getting the last page for a post count
|
// TODO: Create a specialised function with a bit less overhead for getting the last page for a post count
|
||||||
_, _, lastPage := c.PageOffset(t.PostCount, 1, c.Config.ItemsPerPage)
|
_, _, lastPage := c.PageOffset(t.PostCount, 1, c.Config.ItemsPerPage)
|
||||||
|
|
Loading…
Reference in New Issue