Mercurial > prosody-modules
comparison mod_measure_active_users/mod_measure_active_users.lua @ 6350:908d44cfb693
mod_measure_active_users: Add support for mod_account_activity in Prosody 13.0
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 18 Dec 2025 10:43:50 +0000 |
| parents | ca62f9984f4b |
| children |
comparison
equal
deleted
inserted
replaced
| 6349:2d256ea0c157 | 6350:908d44cfb693 |
|---|---|
| 1 local store = module:open_store("lastlog2"); | 1 local is_prosody_13 = prosody.features:contains("loader"); -- proxy for mod_account_activity |
| 2 | |
| 3 local activity_mod = is_prosody_13 and "account_activity" or "lastlog2"; | |
| 4 | |
| 5 local store = module:open_store(activity_mod); | |
| 2 | 6 |
| 3 local measure_d1 = module:measure("active_users_1d", "amount"); | 7 local measure_d1 = module:measure("active_users_1d", "amount"); |
| 4 local measure_d7 = module:measure("active_users_7d", "amount"); | 8 local measure_d7 = module:measure("active_users_7d", "amount"); |
| 5 local measure_d30 = module:measure("active_users_30d", "amount"); | 9 local measure_d30 = module:measure("active_users_30d", "amount"); |
| 6 | 10 |
| 7 local is_enabled = require "core.usermanager".user_is_enabled; | 11 local is_enabled = require "core.usermanager".user_is_enabled; |
| 8 | 12 |
| 9 -- Exclude disabled user accounts from the counts if usermanager supports that API | 13 -- Exclude disabled user accounts from the counts if usermanager supports that API |
| 10 local count_disabled = module:get_option_boolean("measure_active_users_count_disabled", is_enabled == nil); | 14 local count_disabled = module:get_option_boolean("measure_active_users_count_disabled", is_enabled == nil); |
| 11 | 15 |
| 12 local get_last_active = module:depends("lastlog2").get_last_active; | 16 local get_last_active = module:depends(activity_mod).get_last_active; |
| 13 | 17 |
| 14 function update_calculations() | 18 function update_calculations() |
| 15 module:log("debug", "Calculating active users"); | 19 module:log("debug", "Calculating active users"); |
| 16 local host = module.host; | 20 local host = module.host; |
| 17 local host_user_sessions = prosody.hosts[host].sessions; | 21 local host_user_sessions = prosody.hosts[host].sessions; |
