diff options
author | Kim Alvefur <zash@zash.se> | 2021-11-16 16:06:41 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-11-16 16:06:41 +0100 |
commit | ce8107379d68766555cb4b3b7987fc3b3fa9cf73 (patch) | |
tree | f43dcfa49a4967c24d3f732acb62d09e6d823a27 /plugins/mod_admin_shell.lua | |
parent | 6289a2f29d747287168e59659a6d5b2bbf17ad84 (diff) | |
download | prosody-ce8107379d68766555cb4b3b7987fc3b3fa9cf73.tar.gz prosody-ce8107379d68766555cb4b3b7987fc3b3fa9cf73.zip |
mod_admin_shell: Return counts of shown vs total from new table views
Not exactly the way it was before, but close enough and useful.
Diffstat (limited to 'plugins/mod_admin_shell.lua')
-rw-r--r-- | plugins/mod_admin_shell.lua | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua index d0affcaf..a9b855d6 100644 --- a/plugins/mod_admin_shell.lua +++ b/plugins/mod_admin_shell.lua @@ -851,7 +851,11 @@ function def_env.c2s:show(match_jid, colspec) if not group_by_host then print(row()); end local currenthost = nil; - for _, session in ipairs(get_c2s():filter(match):sort(_sort_by_jid)) do + local c2s_sessions = get_c2s(); + local total_count = #c2s_sessions; + c2s_sessions:filter(match):sort(_sort_by_jid); + local shown_count = #c2s_sessions; + for _, session in ipairs(c2s_sessions) do if group_by_host and session.host ~= currenthost then currenthost = session.host; print("#",prosody.hosts[currenthost] or "Unknown host"); @@ -860,7 +864,10 @@ function def_env.c2s:show(match_jid, colspec) print(row(session)); end - return true; + if total_count ~= shown_count then + return true, ("%d out of %d c2s sessions shown"):format(shown_count, total_count); + end + return true, ("%d c2s sessions shown"):format(total_count); end function def_env.c2s:show_tls(match_jid) @@ -927,7 +934,10 @@ function def_env.s2s:show(match_jid, colspec) if not group_by_host then print(row()); end - local s2s_sessions = array(iterators.values(module:shared"/*/s2s/sessions")):filter(match):sort(_sort_s2s); + local s2s_sessions = array(iterators.values(module:shared"/*/s2s/sessions")); + local total_count = #s2s_sessions; + s2s_sessions:filter(match):sort(_sort_s2s); + local shown_count = #s2s_sessions; for _, session in ipairs(s2s_sessions) do if group_by_host and currenthost ~= get_s2s_hosts(session) then @@ -938,7 +948,10 @@ function def_env.s2s:show(match_jid, colspec) print(row(session)); end - return true; -- TODO counts + if total_count ~= shown_count then + return true, ("%d out of %d s2s connections shown"):format(shown_count, total_count); + end + return true, ("%d s2s connections shown"):format(total_count); end function def_env.s2s:show_tls(match_jid) |