Topic views should roughly update once every fifteen minutes in the UI now.
Fixed a bug where int64s wouldn't work properly in transpiled templates. Changed the type of ViewCount in the topic structs to int64.
This commit is contained in:
parent
787108ceda
commit
fd2a35cbcd
|
@ -3,6 +3,7 @@ package counters
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
|
|
||||||
".."
|
".."
|
||||||
"../../query_gen/lib"
|
"../../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)
|
common.DebugLogf("Inserting %d views into topic %d", count, topicID)
|
||||||
_, err := counter.update.Exec(count, topicID)
|
_, err := counter.update.Exec(count, topicID)
|
||||||
|
if err != nil {
|
||||||
return err
|
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) {
|
func (counter *DefaultTopicViewCounter) Bump(topicID int) {
|
||||||
|
|
|
@ -913,7 +913,7 @@ func (c *CTemplateSet) compileVarsub(varname string, val reflect.Value, assLines
|
||||||
out = "w.Write([]byte(" + varname + "))\n"
|
out = "w.Write([]byte(" + varname + "))\n"
|
||||||
case reflect.Int64:
|
case reflect.Int64:
|
||||||
c.importMap["strconv"] = "strconv"
|
c.importMap["strconv"] = "strconv"
|
||||||
out = "w.Write([]byte(strconv.FormatInt(" + varname + ", 10)))"
|
out = "w.Write([]byte(strconv.FormatInt(" + varname + ", 10)))\n"
|
||||||
default:
|
default:
|
||||||
if !val.IsValid() {
|
if !val.IsValid() {
|
||||||
panic(assLines + varname + "^\n" + "Invalid value. Maybe, it doesn't exist?")
|
panic(assLines + varname + "^\n" + "Invalid value. Maybe, it doesn't exist?")
|
||||||
|
|
|
@ -37,7 +37,7 @@ type Topic struct {
|
||||||
ParentID int
|
ParentID int
|
||||||
Status string // Deprecated. Marked for removal.
|
Status string // Deprecated. Marked for removal.
|
||||||
IPAddress string
|
IPAddress string
|
||||||
ViewCount int
|
ViewCount int64
|
||||||
PostCount int
|
PostCount int
|
||||||
LikeCount int
|
LikeCount int
|
||||||
ClassName string // CSS Class Name
|
ClassName string // CSS Class Name
|
||||||
|
@ -61,7 +61,7 @@ type TopicUser struct {
|
||||||
ParentID int
|
ParentID int
|
||||||
Status string // Deprecated. Marked for removal.
|
Status string // Deprecated. Marked for removal.
|
||||||
IPAddress string
|
IPAddress string
|
||||||
ViewCount int
|
ViewCount int64
|
||||||
PostCount int
|
PostCount int
|
||||||
LikeCount int
|
LikeCount int
|
||||||
ClassName string
|
ClassName string
|
||||||
|
@ -99,7 +99,7 @@ type TopicsRow struct {
|
||||||
ParentID int
|
ParentID int
|
||||||
Status string // Deprecated. Marked for removal. -Is there anything we could use it for?
|
Status string // Deprecated. Marked for removal. -Is there anything we could use it for?
|
||||||
IPAddress string
|
IPAddress string
|
||||||
ViewCount int
|
ViewCount int64
|
||||||
PostCount int
|
PostCount int
|
||||||
LikeCount int
|
LikeCount int
|
||||||
ClassName string
|
ClassName string
|
||||||
|
@ -126,7 +126,7 @@ type WsTopicsRow struct {
|
||||||
RelativeLastReplyAt string
|
RelativeLastReplyAt string
|
||||||
LastReplyBy int
|
LastReplyBy int
|
||||||
ParentID int
|
ParentID int
|
||||||
ViewCount int
|
ViewCount int64
|
||||||
PostCount int
|
PostCount int
|
||||||
LikeCount int
|
LikeCount int
|
||||||
ClassName string
|
ClassName string
|
||||||
|
|
Loading…
Reference in New Issue