Add further support for clicks counter
This commit is contained in:
parent
82faacb9ec
commit
376a1264f5
@ -50,6 +50,17 @@ func ServeArticle(c *b.Config, db *b.DB) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Fprint(w, content)
|
||||
article.Clicks++
|
||||
if err = db.UpdateAttributes(&b.Attribute{Table: "articles", ID: article.ID, AttName: "clicks", Value: article.Clicks}); err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err = fmt.Fprint(w, content); err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ CREATE TABLE articles (
|
||||
creator_id INT NOT NULL,
|
||||
issue_id INT NOT NULL,
|
||||
edited_id INT,
|
||||
clicks INT NOT NULL,
|
||||
is_in_issue BOOL NOT NULL,
|
||||
auto_generated BOOL NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
|
Loading…
x
Reference in New Issue
Block a user