From a01d716eedfaf64838dd3d9b1ab265158aadbb04 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 24 Feb 2023 07:39:12 +0100 Subject: [PATCH] stats for user sessions --- modules/structs/stats.go | 1 + routers/api/v1/stats/stats.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/modules/structs/stats.go b/modules/structs/stats.go index 8f73b80..1ee7a4d 100644 --- a/modules/structs/stats.go +++ b/modules/structs/stats.go @@ -3,6 +3,7 @@ package structs // swagger:model StatsResponse type StatsResponse struct { Users int + UserSessions int Chats int WebSocketSessions int UserSignUpProcesses int diff --git a/routers/api/v1/stats/stats.go b/routers/api/v1/stats/stats.go index 4b6a0a1..b05bf4e 100644 --- a/routers/api/v1/stats/stats.go +++ b/routers/api/v1/stats/stats.go @@ -29,6 +29,10 @@ func GetStats(c *fiber.Ctx) error { stats.Users = count } + if count, err := getCount(gocnjhelper.DbMSessions.Name()); err == nil { + stats.UserSessions = count + } + if count, err := getCount(gocnjhelper.DbMChats.Name()); err == nil { stats.Chats = count }