Let's try to gather stats only if the book exist

* Closes: #42
This commit is contained in:
Las Zenow 2018-11-19 02:46:56 +00:00
parent 5bcb08ef37
commit 17b9612f94

View file

@ -137,7 +137,6 @@ func (sg StatsGatherer) worker() {
}
func (sg StatsGatherer) save(req statsRequest) {
var err error
id := mux.Vars(req.r)["id"]
search := strings.Join(req.r.Form["q"], " ")
fmt := req.r.FormValue("fmt")
@ -155,6 +154,11 @@ func (sg StatsGatherer) save(req statsRequest) {
Fmt: fmt,
Duration: req.duration,
})
_, err := sg.db.GetBookID(id)
if err != nil {
return
}
switch section {
case "download":
err = sg.db.IncDownloads(id)