forked from TruthHun/BookStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRankController.go
More file actions
68 lines (64 loc) · 3.06 KB
/
RankController.go
File metadata and controls
68 lines (64 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package controllers
import "github.com/TruthHun/BookStack/models"
type RankController struct {
BaseController
}
func (this *RankController) Index() {
limit, _ := this.GetInt("limit", 50)
if limit > 200 {
limit = 200
}
tab := this.GetString("tab", "all")
switch tab {
case "reading":
rt := models.NewReadingTime()
this.Data["SeoTitle"] = "阅读时长榜"
this.Data["TodayReading"] = rt.Sort(models.PeriodDay, limit, true)
this.Data["WeekReading"] = rt.Sort(models.PeriodWeek, limit, true)
this.Data["MonthReading"] = rt.Sort(models.PeriodMonth, limit, true)
this.Data["LastWeekReading"] = rt.Sort(models.PeriodLastWeek, limit, true)
this.Data["LastMonthReading"] = rt.Sort(models.PeriodLastMoth, limit, true)
this.Data["AllReading"] = rt.Sort(models.PeriodAll, limit, true)
case "sign":
this.Data["SeoTitle"] = "用户签到榜"
sign := models.NewSign()
this.Data["ContinuousSignUsers"] = sign.Sorted(limit, "total_continuous_sign", true)
this.Data["TotalSignUsers"] = sign.Sorted(limit, "total_sign", true)
this.Data["HistoryContinuousSignUsers"] = sign.Sorted(limit, "history_total_continuous_sign", true)
this.Data["ThisMonthSign"] = sign.SortedByPeriod(limit, models.PeriodMonth, true)
this.Data["LastMonthSign"] = sign.SortedByPeriod(limit, models.PeriodLastMoth, true)
case "popular":
this.Data["SeoTitle"] = "文档人气榜"
bookCounter := models.NewBookCounter()
//this.Data["Today"] = bookCounter.PageViewSort(models.PeriodDay, limit, true)
this.Data["Week"] = bookCounter.PageViewSort(models.PeriodWeek, limit, true)
this.Data["Month"] = bookCounter.PageViewSort(models.PeriodMonth, limit, true)
//this.Data["LastWeek"] = bookCounter.PageViewSort(models.PeriodLastWeek, limit, true)
//this.Data["LastMonth"] = bookCounter.PageViewSort(models.PeriodLastMoth, limit, true)
this.Data["All"] = bookCounter.PageViewSort(models.PeriodAll, limit, true)
case "star":
this.Data["SeoTitle"] = "热门收藏榜"
bookCounter := models.NewBookCounter()
//this.Data["Today"] = bookCounter.StarSort(models.PeriodDay, limit, true)
this.Data["Week"] = bookCounter.StarSort(models.PeriodWeek, limit, true)
this.Data["Month"] = bookCounter.StarSort(models.PeriodMonth, limit, true)
//this.Data["LastWeek"] = bookCounter.StarSort(models.PeriodLastWeek, limit, true)
//this.Data["LastMonth"] = bookCounter.StarSort(models.PeriodLastMoth, limit, true)
this.Data["All"] = bookCounter.StarSort(models.PeriodAll, limit, true)
default:
tab = "all"
this.Data["SeoTitle"] = "总榜"
limit = 10
sign := models.NewSign()
book := models.NewBook()
this.Data["ContinuousSignUsers"] = sign.Sorted(limit, "total_continuous_sign", true)
this.Data["ThisMonthSign"] = sign.SortedByPeriod(limit, models.PeriodMonth, true)
this.Data["TotalReadingUsers"] = sign.Sorted(limit, "total_reading_time", true)
this.Data["StarBooks"] = book.Sorted(limit, "star")
this.Data["VcntBooks"] = book.Sorted(limit, "vcnt")
this.Data["CommentBooks"] = book.Sorted(limit, "cnt_comment")
}
this.Data["Tab"] = tab
this.Data["IsRank"] = true
this.TplName = "rank/index.html"
}