gosora/common/statistics.go
Azareal 01a692ab5b Added the word filter store and moved the word filter routes into the route package.
Added tests for the word filter store.
Added qgen.NewAcc() to reduce the amount of boilerplate needed for creating an accumulator.
Exposed the RecordError method on the accumulator.
Added an Add method to PluginList and removed AddPlugin() in favour of that.

More panel buttons on Nox should be styled now.
Added the panel_update_button_text phrase for future use.

More errors might be caught in the thumbnailer now.
Removed ls from .travis.yml, it was there for debugging Code Climate.
2018-08-04 21:46:36 +10:00

39 lines
1011 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 (store *DefaultStatStore) LookupInt(name string, duration int, unit string) (int, error) {
switch name {
case "postCount":
return store.countTable("replies", duration, unit)
}
return 0, errors.New("The requested stat doesn't exist")
}
func (store *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()")