Remove statistics and add frequent tags in memory

This commit is contained in:
Las Zenow 2016-09-03 15:08:10 -04:00
parent 284b649b69
commit 18baa2938b
10 changed files with 35 additions and 256 deletions

View file

@ -22,22 +22,17 @@ type DB interface {
GetNews(num int, days int) (news []New, err error)
AddStats(stats interface{}) error
GetVisitedBooks() (books []Book, err error)
UpdateMostVisited() error
GetDownloadedBooks() (books []Book, err error)
UpdateDownloadedBooks() error
GetTags() ([]string, error)
UpdateTags() error
GetVisits(visitType VisitType) ([]Visits, error)
UpdateHourVisits() error
UpdateDayVisits() error
UpdateMonthVisits() error
UpdateHourDownloads() error
UpdateDayDownloads() error
UpdateMonthDownloads() error
}
const (
tagsDisplay = 50
)
type pgDB struct {
sql *pg.DB
sql *pg.DB
tags []string
}
// Options for the database
@ -57,7 +52,11 @@ func Init(options Options) (DB, error) {
Database: options.Name,
})
// TODO: create db
return &pgDB{sql}, nil
db := pgDB{sql, []string{}}
go db.tagUpdater()
return &db, nil
}
// Close the database connection