Convert config.go into command line params
This commit is contained in:
parent
9d1f1ad5c0
commit
0e8f1e7b56
14 changed files with 217 additions and 189 deletions
31
lib/stats.go
31
lib/stats.go
|
@ -15,27 +15,34 @@ import (
|
|||
|
||||
const (
|
||||
stats_version = 2
|
||||
statsChanSize = 100
|
||||
)
|
||||
|
||||
type handler struct {
|
||||
w http.ResponseWriter
|
||||
r *http.Request
|
||||
sess *Session
|
||||
db *database.DB
|
||||
store *storage.Store
|
||||
w http.ResponseWriter
|
||||
r *http.Request
|
||||
sess *Session
|
||||
db *database.DB
|
||||
store *storage.Store
|
||||
template *Template
|
||||
hostname string
|
||||
}
|
||||
|
||||
type StatsGatherer struct {
|
||||
db *database.DB
|
||||
store *storage.Store
|
||||
channel chan statsRequest
|
||||
db *database.DB
|
||||
store *storage.Store
|
||||
template *Template
|
||||
hostname string
|
||||
channel chan statsRequest
|
||||
}
|
||||
|
||||
func InitStats(database *database.DB, store *storage.Store) *StatsGatherer {
|
||||
func InitStats(database *database.DB, store *storage.Store, hostname string, template *Template) *StatsGatherer {
|
||||
sg := new(StatsGatherer)
|
||||
sg.channel = make(chan statsRequest, CHAN_SIZE)
|
||||
sg.channel = make(chan statsRequest, statsChanSize)
|
||||
sg.db = database
|
||||
sg.store = store
|
||||
sg.template = template
|
||||
sg.hostname = hostname
|
||||
|
||||
go sg.worker()
|
||||
return sg
|
||||
|
@ -49,6 +56,8 @@ func (sg StatsGatherer) Gather(function func(handler)) func(http.ResponseWriter,
|
|||
h.store = sg.store
|
||||
h.db = sg.db.Copy()
|
||||
defer h.db.Close()
|
||||
h.template = sg.template
|
||||
h.hostname = sg.hostname
|
||||
|
||||
h.w = w
|
||||
h.r = r
|
||||
|
@ -96,7 +105,7 @@ func statsHandler(h handler) {
|
|||
data.DDownloads = getVisits(dailyLabel, h.db, database.Daily_downloads)
|
||||
data.MDownloads = getVisits(monthlyLabel, h.db, database.Monthly_downloads)
|
||||
|
||||
loadTemplate(h, "stats", data)
|
||||
h.template.load(h, "stats", data)
|
||||
}
|
||||
|
||||
type statsData struct {
|
||||
|
|
Reference in a new issue