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

Method GetStats

models/ebook.go:115–139  ·  view source on GitHub ↗

电子书状态(最新的状态)

(bookID int)

Source from the content-addressed store, hash-verified

113
114// 电子书状态(最新的状态)
115func (m *Ebook) GetStats(bookID int) (stats map[string]Ebook) {
116 var (
117 ebooks []Ebook
118 limit = 4 // 先默认为4,即四个扩展名:.pdf,.epub,.mobi,.docx
119 )
120 stats = make(map[string]Ebook)
121 o := orm.NewOrm()
122 o.QueryTable(m).Filter("book_id", bookID).OrderBy("-id").Limit(limit).All(&ebooks)
123 if len(ebooks) == 0 {
124 stats = map[string]Ebook{
125 "PDF": {Status: -1},
126 "EPUB": {Status: -1},
127 "MOBI": {Status: -1},
128 }
129 return
130 }
131
132 for _, ebook := range ebooks {
133 ext := strings.TrimLeft(strings.ToUpper(ebook.Ext), ".")
134 if _, ok := stats[ext]; !ok {
135 stats[ext] = ebook
136 }
137 }
138 return
139}
140
141// 查询书籍是否处于完成状态。失败也是完成状态的一种。
142func (m *Ebook) IsFinish(bookID int) (ok bool) {

Callers 1

IndexMethod · 0.95

Calls 1

AllMethod · 0.45

Tested by

no test coverage detected