Skip to content

Commit

Permalink
encrypted messages stats (#20)
Browse files Browse the repository at this point in the history
Add stats for encrypted messages.
  • Loading branch information
jcgruenhage committed Feb 22, 2021
1 parent d970da5 commit 7b741cc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
13 changes: 11 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ type StatsReport struct {
TotalNonBridgedUsers *int64 `json:"total_nonbridged_users"` // Total native and guest users in users table
TotalRoomCount *int64 `json:"total_room_count"` // Total number of rooms on the server
DailyActiveUsers *int64 `json:"daily_active_users"` // Total number of users in the users ips table seen in the last 24 hours
DailyMessages *int64 `json:"daily_messages"` // Total number of m.room.message in events table in the past 24 hours sent from host server
DailySentMessages *int64 `json:"daily_sent_messages"` // Total number of m.room.message in events table in the past 24 hours
DailyMessages *int64 `json:"daily_messages"` // Total number of m.room.message in events table in the past 24 hours
DailySentMessages *int64 `json:"daily_sent_messages"` // Total number of m.room.message in events table in the past 24 hours sent from host server
DailyActiveRooms *int64 `json:"daily_active_rooms"` // Total number of rooms with a m.room.message in the event table in the past 24 hours
DailyE2eeMessages *int64 `json:"daily_e2ee_messages"` // Total number of m.room.encrypted in events table in the past 24 hours
DailySentE2eeMessages *int64 `json:"daily_sent_e2ee_messages"` // Total number of m.room.encrypted in events table in the past 24 hours sent from host server
DailyActiveE2eeRooms *int64 `json:"daily_active_e2ee_rooms"` // Total number of rooms with a m.room.encrypted in the event table in the past 24 hours
MonthlyActiveUsers *int64 `json:"monthly_active_users"` // Total number of users in the users ips table seen in the last 30 days
R30UsersAll *int64 `json:"r30_users_all"` // r30 stat for all users regardless of client
R30UsersAndroid *int64 `json:"r30_users_android"` // r30 stat considering only Riot Android
Expand Down Expand Up @@ -131,6 +134,9 @@ func (r *Recorder) Save(sr StatsReport) error {
cols, vals = appendIfNonNil(cols, vals, "daily_active_rooms", sr.DailyActiveRooms)
cols, vals = appendIfNonNil(cols, vals, "daily_messages", sr.DailyMessages)
cols, vals = appendIfNonNil(cols, vals, "daily_sent_messages", sr.DailySentMessages)
cols, vals = appendIfNonNil(cols, vals, "daily_active_e2ee_rooms", sr.DailyActiveE2eeRooms)
cols, vals = appendIfNonNil(cols, vals, "daily_e2ee_messages", sr.DailyE2eeMessages)
cols, vals = appendIfNonNil(cols, vals, "daily_sent_e2ee_messages", sr.DailySentE2eeMessages)
cols, vals = appendIfNonNil(cols, vals, "monthly_active_users", sr.MonthlyActiveUsers)

cols, vals = appendIfNonNil(cols, vals, "r30_users_all", sr.R30UsersAll)
Expand Down Expand Up @@ -229,6 +235,9 @@ func createTable(db *sql.DB) error {
daily_active_rooms BIGINT,
daily_messages BIGINT,
daily_sent_messages BIGINT,
daily_active_e2ee_rooms BIGINT,
daily_e2ee_messages BIGINT,
daily_sent_e2ee_messages BIGINT,
monthly_active_users BIGINT,
r30_users_all BIGINT,
r30_users_android BIGINT,
Expand Down
9 changes: 9 additions & 0 deletions scripts/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def main():
`daily_active_rooms` bigint(20) DEFAULT NULL,
`daily_messages` bigint(20) DEFAULT NULL,
`daily_sent_messages` bigint(20) DEFAULT NULL,
`daily_active_e2ee_rooms` bigint(20) DEFAULT NULL,
`daily_e2ee_messages` bigint(20) DEFAULT NULL,
`daily_sent_e2ee_messages` bigint(20) DEFAULT NULL,
`monthly_active_users` bigint(20) DEFAULT NULL,
`r30_users_all` bigint(20) DEFAULT NULL,
`r30_users_android` bigint(20) DEFAULT NULL,
Expand Down Expand Up @@ -98,6 +101,9 @@ def main():
SUM(daily_active_rooms) as 'daily_active_rooms',
SUM(daily_messages) as 'daily_messages',
SUM(daily_sent_messages) as 'daily_sent_messages',
SUM(daily_active_e2ee_rooms) as 'daily_active_e2ee_rooms',
SUM(daily_e2ee_messages) as 'daily_e2ee_messages',
SUM(daily_sent_e2ee_messages) as 'daily_sent_e2ee_messages',
SUM(monthly_active_users) as 'monthly_active_users',
SUM(r30_users_all) as 'r30_users_all',
SUM(r30_users_android) as 'r30_users_android',
Expand Down Expand Up @@ -132,6 +138,9 @@ def main():
daily_active_rooms,
daily_messages,
daily_sent_messages,
daily_active_e2ee_rooms,
daily_e2ee_messages,
daily_sent_e2ee_messages,
monthly_active_users,
r30_users_all,
r30_users_android,
Expand Down

0 comments on commit 7b741cc

Please sign in to comment.