|
|
@ -30,8 +30,11 @@ func NodeInfo(ctx *context.APIContext) { |
|
|
|
|
|
|
|
|
|
|
|
nodeInfoUsage := structs.NodeInfoUsage{} |
|
|
|
nodeInfoUsage := structs.NodeInfoUsage{} |
|
|
|
if setting.Federation.ShareUserStatistics { |
|
|
|
if setting.Federation.ShareUserStatistics { |
|
|
|
info, ok := ctx.Cache.Get(cacheKeyNodeInfoUsage).(structs.NodeInfoUsage) |
|
|
|
cached := false |
|
|
|
if !ok { |
|
|
|
if setting.CacheService.Enabled { |
|
|
|
|
|
|
|
nodeInfoUsage, cached = ctx.Cache.Get(cacheKeyNodeInfoUsage).(structs.NodeInfoUsage) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if !cached { |
|
|
|
usersTotal := int(user_model.CountUsers(nil)) |
|
|
|
usersTotal := int(user_model.CountUsers(nil)) |
|
|
|
now := time.Now() |
|
|
|
now := time.Now() |
|
|
|
timeOneMonthAgo := now.AddDate(0, -1, 0).Unix() |
|
|
|
timeOneMonthAgo := now.AddDate(0, -1, 0).Unix() |
|
|
@ -42,7 +45,7 @@ func NodeInfo(ctx *context.APIContext) { |
|
|
|
allIssues, _ := models.CountIssues(&models.IssuesOptions{}) |
|
|
|
allIssues, _ := models.CountIssues(&models.IssuesOptions{}) |
|
|
|
allComments, _ := models.CountComments(&models.FindCommentsOptions{}) |
|
|
|
allComments, _ := models.CountComments(&models.FindCommentsOptions{}) |
|
|
|
|
|
|
|
|
|
|
|
info = structs.NodeInfoUsage{ |
|
|
|
nodeInfoUsage = structs.NodeInfoUsage{ |
|
|
|
Users: structs.NodeInfoUsageUsers{ |
|
|
|
Users: structs.NodeInfoUsageUsers{ |
|
|
|
Total: usersTotal, |
|
|
|
Total: usersTotal, |
|
|
|
ActiveMonth: usersActiveMonth, |
|
|
|
ActiveMonth: usersActiveMonth, |
|
|
@ -51,12 +54,13 @@ func NodeInfo(ctx *context.APIContext) { |
|
|
|
LocalPosts: int(allIssues), |
|
|
|
LocalPosts: int(allIssues), |
|
|
|
LocalComments: int(allComments), |
|
|
|
LocalComments: int(allComments), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if setting.CacheService.Enabled { |
|
|
|
if err := ctx.Cache.Put(cacheKeyNodeInfoUsage, nodeInfoUsage, 180); err != nil { |
|
|
|
if err := ctx.Cache.Put(cacheKeyNodeInfoUsage, nodeInfoUsage, 180); err != nil { |
|
|
|
ctx.InternalServerError(err) |
|
|
|
ctx.InternalServerError(err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
nodeInfoUsage = info |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
nodeInfo := &structs.NodeInfo{ |
|
|
|
nodeInfo := &structs.NodeInfo{ |
|
|
|