gosora/common/statistics.go
Azareal 78c5c62eee Basic group promotions.
Add the users_groups_promotions table.
Optimise ConvoViewPage.

Shortened some things.
Convo CSS fixes.
Make sure the user cache is flushed properly after the post stats change.

You will need to run the patcher / updater for this commit.
2019-09-29 14:56:39 +10:00

39 lines
999 B
Go

package common
// EXPERIMENTAL
import (
"errors"
)
var StatStore StatStoreInt
type StatStoreInt interface {
LookupInt(name string, duration int, unit string) (int, error)
}
type DefaultStatStore struct {
}
func NewDefaultStatStore() *DefaultStatStore {
return &DefaultStatStore{}
}
func (s *DefaultStatStore) LookupInt(name string, duration int, unit string) (int, error) {
switch name {
case "postCount":
return s.countTable("replies", duration, unit)
}
return 0, errors.New("The requested stat doesn't exist")
}
func (s *DefaultStatStore) countTable(table string, duration int, unit string) (stat int, err error) {
/*counter := qgen.NewAcc().Count("replies").DateCutoff("createdAt", 1, "day").Prepare()
if acc.FirstError() != nil {
return 0, acc.FirstError()
}
err := counter.QueryRow().Scan(&stat)*/
return stat, err
}
//stmts.todaysPostCount, err = db.Prepare("select count(*) from replies where createdAt BETWEEN (utc_timestamp() - interval 1 day) and utc_timestamp()")