Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 29d45b6

Browse files
committed
search stat bugfix
1 parent 345ad1a commit 29d45b6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

websites/code/studygolang/src/service/searcher.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ func DoSearch(q, field string, start, rows int) (*model.ResponseBody, error) {
145145
values.Add("q", "*:*")
146146
} else {
147147
searchStat := model.NewSearchStat()
148-
searchStat.Find()
148+
searchStat.Where("keyword=?", q).Find()
149149
if searchStat.Id > 0 {
150-
searchStat.Increment("times", 1)
150+
searchStat.Where("keyword=?", q).Increment("times", 1)
151151
} else {
152152
searchStat.Keyword = q
153153
searchStat.Times = 1
154154
_, err := searchStat.Insert()
155155
if err != nil {
156-
searchStat.Increment("times", 1)
156+
searchStat.Where("keyword=?", q).Increment("times", 1)
157157
}
158158
}
159159
}

0 commit comments

Comments
 (0)