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

Method Rank

controllers/api/CommonController.go:1196–1255  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1194}
1195
1196func (this *CommonController) Rank() {
1197 limit, _ := this.GetInt("limit", 50)
1198 if limit > 200 {
1199 limit = 200
1200 }
1201
1202 data := make(map[string]interface{})
1203
1204 tab := this.GetString("tab", "all")
1205 switch tab {
1206 case "reading":
1207 rt := models.NewReadingTime()
1208 data["today"] = rt.Sort(models.PeriodDay, limit, true)
1209 data["week"] = rt.Sort(models.PeriodWeek, limit, true)
1210 data["month"] = rt.Sort(models.PeriodMonth, limit, true)
1211 data["last_week"] = rt.Sort(models.PeriodLastWeek, limit, true)
1212 data["last_month"] = rt.Sort(models.PeriodLastMoth, limit, true)
1213 data["all"] = rt.Sort(models.PeriodAll, limit, true)
1214 case "sign":
1215 sign := models.NewSign()
1216 data["continuous_sign"] = sign.Sorted(limit, "total_continuous_sign", true)
1217 data["total_sign"] = sign.Sorted(limit, "total_sign", true)
1218 data["this_month_sign"] = sign.SortedByPeriod(limit, models.PeriodMonth, true)
1219 data["last_month_sign"] = sign.SortedByPeriod(limit, models.PeriodLastMoth, true)
1220 data["history_continuous_sign"] = sign.Sorted(limit, "history_total_continuous_sign", true)
1221 case "popular":
1222 bookCounter := models.NewBookCounter()
1223 data["today"] = bookCounter.PageViewSort(models.PeriodDay, limit, true)
1224 data["week"] = bookCounter.PageViewSort(models.PeriodWeek, limit, true)
1225 data["month"] = bookCounter.PageViewSort(models.PeriodMonth, limit, true)
1226 data["last_week"] = bookCounter.PageViewSort(models.PeriodLastWeek, limit, true)
1227 data["last_month"] = bookCounter.PageViewSort(models.PeriodLastMoth, limit, true)
1228 data["all"] = bookCounter.PageViewSort(models.PeriodAll, limit, true)
1229 case "star":
1230 bookCounter := models.NewBookCounter()
1231 data["today"] = bookCounter.StarSort(models.PeriodDay, limit, true)
1232 data["week"] = bookCounter.StarSort(models.PeriodWeek, limit, true)
1233 data["month"] = bookCounter.StarSort(models.PeriodMonth, limit, true)
1234 data["last_week"] = bookCounter.StarSort(models.PeriodLastWeek, limit, true)
1235 data["last_month"] = bookCounter.StarSort(models.PeriodLastMoth, limit, true)
1236 data["all"] = bookCounter.StarSort(models.PeriodAll, limit, true)
1237 default:
1238 tab = "all"
1239 sign := models.NewSign()
1240 book := models.NewBook()
1241 data["continuous_sign"] = sign.Sorted(limit, "total_continuous_sign", true)
1242 data["total_sign"] = sign.Sorted(limit, "total_sign", true)
1243 data["star_books"] = book.Sorted(limit, "star")
1244 data["vcnt_books"] = book.Sorted(limit, "vcnt")
1245 data["comment_books"] = book.Sorted(limit, "cnt_comment")
1246 // 这里要适配一下APP端,将错就错的写法,转换一下字段
1247 readers := models.NewReadingTime().Sort(models.PeriodAll, limit, true)
1248 for idx, reader := range readers {
1249 reader.TotalReadingTime = reader.SumTime
1250 readers[idx] = reader
1251 }
1252 data["total_reading"] = readers
1253 }

Callers

nothing calls this directly

Calls 11

SortMethod · 0.95
SortedMethod · 0.95
SortedByPeriodMethod · 0.95
PageViewSortMethod · 0.95
StarSortMethod · 0.95
SortedMethod · 0.95
NewReadingTimeFunction · 0.92
NewSignFunction · 0.92
NewBookCounterFunction · 0.92
NewBookFunction · 0.92
ResponseMethod · 0.80

Tested by

no test coverage detected