Add download counter on each book

* Closes: #40
This commit is contained in:
Las Zenow 2018-11-19 03:14:26 +00:00
parent fb399ac973
commit 8b996803c8
5 changed files with 30 additions and 5 deletions

View file

@ -40,6 +40,15 @@ func (db *pgDB) IncDownloads(ID string) error {
return err
}
func (db *pgDB) GetDownloadCounter(ID string) (int, error) {
var num int
err := db.sql.Model(&Visit{}).
Column("downloads").
Where("book_id = ?", ID).
Select(&num)
return num, err
}
func (db *pgDB) GetFrontPage() FrontPage {
return db.frontPage
}