feat: cache dashboard site summary
This commit is contained in:
parent
13d36c25d4
commit
0c9383e329
1 changed files with 28 additions and 18 deletions
|
@ -70,6 +70,21 @@ func (service *BatchSettingChangeService) Change() serializer.Response {
|
||||||
|
|
||||||
// Summary 获取站点统计概况
|
// Summary 获取站点统计概况
|
||||||
func (service *NoParamService) Summary() serializer.Response {
|
func (service *NoParamService) Summary() serializer.Response {
|
||||||
|
// 获取版本信息
|
||||||
|
versions := map[string]string{
|
||||||
|
"backend": conf.BackendVersion,
|
||||||
|
"db": conf.RequiredDBVersion,
|
||||||
|
"commit": conf.LastCommit,
|
||||||
|
"is_pro": conf.IsPro,
|
||||||
|
}
|
||||||
|
|
||||||
|
if res, ok := cache.Get("admin_summary"); ok {
|
||||||
|
resMap := res.(map[string]interface{})
|
||||||
|
resMap["version"] = versions
|
||||||
|
resMap["siteURL"] = model.GetSettingByName("siteURL")
|
||||||
|
return serializer.Response{Data: resMap}
|
||||||
|
}
|
||||||
|
|
||||||
// 统计每日概况
|
// 统计每日概况
|
||||||
total := 12
|
total := 12
|
||||||
files := make([]int, total)
|
files := make([]int, total)
|
||||||
|
@ -98,16 +113,7 @@ func (service *NoParamService) Summary() serializer.Response {
|
||||||
model.DB.Model(&model.Share{}).Where("password = ?", "").Count(&publicShareTotal)
|
model.DB.Model(&model.Share{}).Where("password = ?", "").Count(&publicShareTotal)
|
||||||
model.DB.Model(&model.Share{}).Where("password <> ?", "").Count(&secretShareTotal)
|
model.DB.Model(&model.Share{}).Where("password <> ?", "").Count(&secretShareTotal)
|
||||||
|
|
||||||
// 获取版本信息
|
resp := map[string]interface{}{
|
||||||
versions := map[string]string{
|
|
||||||
"backend": conf.BackendVersion,
|
|
||||||
"db": conf.RequiredDBVersion,
|
|
||||||
"commit": conf.LastCommit,
|
|
||||||
"is_pro": conf.IsPro,
|
|
||||||
}
|
|
||||||
|
|
||||||
return serializer.Response{
|
|
||||||
Data: map[string]interface{}{
|
|
||||||
"date": date,
|
"date": date,
|
||||||
"files": files,
|
"files": files,
|
||||||
"users": users,
|
"users": users,
|
||||||
|
@ -118,6 +124,10 @@ func (service *NoParamService) Summary() serializer.Response {
|
||||||
"userTotal": userTotal,
|
"userTotal": userTotal,
|
||||||
"publicShareTotal": publicShareTotal,
|
"publicShareTotal": publicShareTotal,
|
||||||
"secretShareTotal": secretShareTotal,
|
"secretShareTotal": secretShareTotal,
|
||||||
},
|
}
|
||||||
|
|
||||||
|
cache.Set("admin_summary", resp, 86400)
|
||||||
|
return serializer.Response{
|
||||||
|
Data: resp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue