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

Method GetReadingTime

models/reading_time.go:56–69  ·  view source on GitHub ↗
(uid int, prd period)

Source from the content-addressed store, hash-verified

54}
55
56func (r *ReadingTime) GetReadingTime(uid int, prd period) int {
57 sum := &sum{}
58 o := orm.NewOrm()
59 sqlSum := "select sum(duration) sum_val from md_reading_time where uid = ? and day>=? and day<=? limit 1"
60 now := time.Now()
61 if prd == PeriodAll {
62 m := NewMember()
63 o.QueryTable(m).Filter("member_id", uid).One(m, "total_reading_time")
64 return m.TotalReadingTime
65 }
66 start, end := getTimeRange(now, prd)
67 o.Raw(sqlSum, uid, start, end).QueryRow(sum)
68 return sum.SumVal
69}
70
71func (r *ReadingTime) Sort(prd period, limit int, withCache ...bool) (users []ReadingSortedUser) {
72 var b []byte

Callers 3

PrepareMethod · 0.95
GetUserMoreInfoMethod · 0.95
DoesICanDownloadMethod · 0.80

Calls 2

NewMemberFunction · 0.85
getTimeRangeFunction · 0.85

Tested by

no test coverage detected