From 17b9612f94fea0b82fef1f153ae0de41cff4dcd1 Mon Sep 17 00:00:00 2001 From: Las Zenow Date: Mon, 19 Nov 2018 02:46:56 +0000 Subject: [PATCH] Let's try to gather stats only if the book exist * Closes: #42 --- lib/stats.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/stats.go b/lib/stats.go index 8927704..bb68514 100644 --- a/lib/stats.go +++ b/lib/stats.go @@ -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)