mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Adding active users statistics to system console (#5141)
This commit is contained in:
committed by
enahum
parent
66dddbdb78
commit
11a688d381
26
api/admin.go
26
api/admin.go
@@ -25,6 +25,11 @@ import (
|
||||
"github.com/mssola/user_agent"
|
||||
)
|
||||
|
||||
const (
|
||||
DAY_MILLISECONDS = 24 * 60 * 60 * 1000
|
||||
MONTH_MILLISECONDS = 31 * DAY_MILLISECONDS
|
||||
)
|
||||
|
||||
func InitAdmin() {
|
||||
l4g.Debug(utils.T("api.admin.init.debug"))
|
||||
|
||||
@@ -382,7 +387,7 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if name == "standard" {
|
||||
var rows model.AnalyticsRows = make([]*model.AnalyticsRow, 8)
|
||||
var rows model.AnalyticsRows = make([]*model.AnalyticsRow, 10)
|
||||
rows[0] = &model.AnalyticsRow{"channel_open_count", 0}
|
||||
rows[1] = &model.AnalyticsRow{"channel_private_count", 0}
|
||||
rows[2] = &model.AnalyticsRow{"post_count", 0}
|
||||
@@ -391,6 +396,8 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
rows[5] = &model.AnalyticsRow{"total_websocket_connections", 0}
|
||||
rows[6] = &model.AnalyticsRow{"total_master_db_connections", 0}
|
||||
rows[7] = &model.AnalyticsRow{"total_read_db_connections", 0}
|
||||
rows[8] = &model.AnalyticsRow{"daily_active_users", 0}
|
||||
rows[9] = &model.AnalyticsRow{"monthly_active_users", 0}
|
||||
|
||||
openChan := app.Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_OPEN)
|
||||
privateChan := app.Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_PRIVATE)
|
||||
@@ -406,6 +413,9 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
postChan = app.Srv.Store.Post().AnalyticsPostCount(teamId, false, false)
|
||||
}
|
||||
|
||||
dailyActiveChan := app.Srv.Store.User().AnalyticsActiveCount(DAY_MILLISECONDS)
|
||||
monthlyActiveChan := app.Srv.Store.User().AnalyticsActiveCount(MONTH_MILLISECONDS)
|
||||
|
||||
if r := <-openChan; r.Err != nil {
|
||||
c.Err = r.Err
|
||||
return
|
||||
@@ -477,6 +487,20 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
rows[7].Value = float64(app.Srv.Store.TotalReadDbConnections())
|
||||
}
|
||||
|
||||
if r := <-dailyActiveChan; r.Err != nil {
|
||||
c.Err = r.Err
|
||||
return
|
||||
} else {
|
||||
rows[8].Value = float64(r.Data.(int64))
|
||||
}
|
||||
|
||||
if r := <-monthlyActiveChan; r.Err != nil {
|
||||
c.Err = r.Err
|
||||
return
|
||||
} else {
|
||||
rows[9].Value = float64(r.Data.(int64))
|
||||
}
|
||||
|
||||
w.Write([]byte(rows.ToJson()))
|
||||
} else if name == "post_counts_day" {
|
||||
if skipIntensiveQueries {
|
||||
|
||||
Reference in New Issue
Block a user