diff --git a/common/counters/topics_views.go b/common/counters/topics_views.go index 8de55e79..e5e81d16 100644 --- a/common/counters/topics_views.go +++ b/common/counters/topics_views.go @@ -3,6 +3,7 @@ package counters import ( "database/sql" "sync" + "sync/atomic" ".." "../../query_gen/lib" @@ -82,7 +83,16 @@ func (counter *DefaultTopicViewCounter) insertChunk(count int, topicID int) erro } common.DebugLogf("Inserting %d views into topic %d", count, topicID) _, err := counter.update.Exec(count, topicID) - return err + if err != nil { + return err + } + // TODO: Add a way to disable this for extra speed ;) + topic, err := common.Topics.Get(topicID) + if err != nil { + return err + } + atomic.AddInt64(&topic.ViewCount, int64(count)) + return nil } func (counter *DefaultTopicViewCounter) Bump(topicID int) { diff --git a/common/templates/templates.go b/common/templates/templates.go index 362a05f2..f0964d62 100644 --- a/common/templates/templates.go +++ b/common/templates/templates.go @@ -913,7 +913,7 @@ func (c *CTemplateSet) compileVarsub(varname string, val reflect.Value, assLines out = "w.Write([]byte(" + varname + "))\n" case reflect.Int64: c.importMap["strconv"] = "strconv" - out = "w.Write([]byte(strconv.FormatInt(" + varname + ", 10)))" + out = "w.Write([]byte(strconv.FormatInt(" + varname + ", 10)))\n" default: if !val.IsValid() { panic(assLines + varname + "^\n" + "Invalid value. Maybe, it doesn't exist?") diff --git a/common/topic.go b/common/topic.go index d4b74787..5b634d7a 100644 --- a/common/topic.go +++ b/common/topic.go @@ -37,7 +37,7 @@ type Topic struct { ParentID int Status string // Deprecated. Marked for removal. IPAddress string - ViewCount int + ViewCount int64 PostCount int LikeCount int ClassName string // CSS Class Name @@ -61,7 +61,7 @@ type TopicUser struct { ParentID int Status string // Deprecated. Marked for removal. IPAddress string - ViewCount int + ViewCount int64 PostCount int LikeCount int ClassName string @@ -99,7 +99,7 @@ type TopicsRow struct { ParentID int Status string // Deprecated. Marked for removal. -Is there anything we could use it for? IPAddress string - ViewCount int + ViewCount int64 PostCount int LikeCount int ClassName string @@ -126,7 +126,7 @@ type WsTopicsRow struct { RelativeLastReplyAt string LastReplyBy int ParentID int - ViewCount int + ViewCount int64 PostCount int LikeCount int ClassName string