@@ -30,8 +30,11 @@ func NodeInfo(ctx *context.APIContext) {
3030
3131 nodeInfoUsage := structs.NodeInfoUsage {}
3232 if setting .Federation .ShareUserStatistics {
33- info , ok := ctx .Cache .Get (cacheKeyNodeInfoUsage ).(structs.NodeInfoUsage )
34- if ! ok {
33+ cached := false
34+ if setting .CacheService .Enabled {
35+ nodeInfoUsage , cached = ctx .Cache .Get (cacheKeyNodeInfoUsage ).(structs.NodeInfoUsage )
36+ }
37+ if ! cached {
3538 usersTotal := int (user_model .CountUsers (nil ))
3639 now := time .Now ()
3740 timeOneMonthAgo := now .AddDate (0 , - 1 , 0 ).Unix ()
@@ -42,7 +45,7 @@ func NodeInfo(ctx *context.APIContext) {
4245 allIssues , _ := models .CountIssues (& models.IssuesOptions {})
4346 allComments , _ := models .CountComments (& models.FindCommentsOptions {})
4447
45- info = structs.NodeInfoUsage {
48+ nodeInfoUsage = structs.NodeInfoUsage {
4649 Users : structs.NodeInfoUsageUsers {
4750 Total : usersTotal ,
4851 ActiveMonth : usersActiveMonth ,
@@ -51,12 +54,13 @@ func NodeInfo(ctx *context.APIContext) {
5154 LocalPosts : int (allIssues ),
5255 LocalComments : int (allComments ),
5356 }
54- if err := ctx .Cache .Put (cacheKeyNodeInfoUsage , nodeInfoUsage , 180 ); err != nil {
55- ctx .InternalServerError (err )
56- return
57+ if setting .CacheService .Enabled {
58+ if err := ctx .Cache .Put (cacheKeyNodeInfoUsage , nodeInfoUsage , 180 ); err != nil {
59+ ctx .InternalServerError (err )
60+ return
61+ }
5762 }
5863 }
59- nodeInfoUsage = info
6064 }
6165
6266 nodeInfo := & structs.NodeInfo {
0 commit comments