MCPcopy Index your code
hub / github.com/TruthHun/BookStack / Increase

Method Increase

models/book_counter.go:53–77  ·  view source on GitHub ↗
(bookId int, isPV bool)

Source from the content-addressed store, hash-verified

51}
52
53func (*BookCounter) Increase(bookId int, isPV bool) {
54 sc := NewBookCounter()
55 today, _ := strconv.Atoi(time.Now().Format(dateFormat))
56 o := orm.NewOrm()
57 o.QueryTable(sc).Filter("bid", bookId).Filter("day", today).One(sc)
58 if sc.Id == 0 {
59 sc = &BookCounter{
60 Bid: bookId,
61 Day: today,
62 }
63 if isPV {
64 sc.ViewCnt = 1
65 } else {
66 sc.StarCnt = 1
67 }
68 o.Insert(sc)
69 } else {
70 if isPV {
71 sc.ViewCnt += 1
72 } else {
73 sc.StarCnt += 1
74 }
75 o.Update(sc)
76 }
77}
78
79func (*BookCounter) Decrease(bookId int, isPV bool) {
80 sc := NewBookCounter()

Callers 2

StarMethod · 0.95
ReadMethod · 0.45

Calls 3

NewBookCounterFunction · 0.85
InsertMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected