diff --git a/src/models.go b/src/models.go index 410552d..6a7329f 100644 --- a/src/models.go +++ b/src/models.go @@ -11,11 +11,10 @@ import ( type D map[string]interface{} type Instance struct { - Debug bool - DB *DB Config *Config + Debug bool - addr string + db *DB router *mux.Router tmpls *template.Template } diff --git a/src/updater.go b/src/updater.go index 02dd87e..7ed41bb 100644 --- a/src/updater.go +++ b/src/updater.go @@ -18,7 +18,7 @@ type RawServerData struct { func (i *Instance) UpdateServers() { reset() - tx := i.DB.NewTransaction() + tx := i.db.NewTransaction() if i.Debug { fmt.Println("\nPolling servers...") @@ -76,7 +76,7 @@ func isupdated(title string) bool { func (i *Instance) get_old_servers() []*RawServerData { var tmp []*RawServerData - for _, old := range i.DB.GetOldServers(Now()) { + for _, old := range i.db.GetOldServers(Now()) { s := RawServerData{ Title: old.Title, Game_url: old.GameUrl, diff --git a/src/web.go b/src/web.go index 1ec4665..ed3cb13 100644 --- a/src/web.go +++ b/src/web.go @@ -25,9 +25,10 @@ func New(debug bool, path string) (*Instance, error) { db.InitSchema() i := Instance{ - Debug: debug, - DB: db, Config: c, + Debug: debug, + + db: db, } return &i, nil @@ -114,7 +115,7 @@ func (i *Instance) page_404(w http.ResponseWriter, r *http.Request) { } func (i *Instance) page_index(w http.ResponseWriter, r *http.Request) { - servers := i.DB.AllServers() + servers := i.db.AllServers() i.tmpls.ExecuteTemplate(w, "page_index.html", D{ "pagetitle": "Index", "servers": servers, @@ -132,7 +133,7 @@ func (i *Instance) page_server(w http.ResponseWriter, r *http.Request) { return } - s, err := i.DB.GetServer(int(id)) + s, err := i.db.GetServer(int(id)) if err != nil { i.page_404(w, r) return @@ -153,8 +154,8 @@ func (i *Instance) page_server(w http.ResponseWriter, r *http.Request) { i.tmpls.ExecuteTemplate(w, "page_server.html", D{ "pagetitle": s.Title, "server": s, - "weekhistory": i.DB.GetServerPopulation(int(id), time.Duration(7*24+12)*time.Hour), - "monthhistory": i.DB.GetServerPopulation(int(id), time.Duration(31*24)*time.Hour), + "weekhistory": i.db.GetServerPopulation(int(id), time.Duration(7*24+12)*time.Hour), + "monthhistory": i.db.GetServerPopulation(int(id), time.Duration(31*24)*time.Hour), "weekdayavg": weekdayavg, }) }