diff options
author | metamuffin <metamuffin@disroot.org> | 2024-11-13 21:10:29 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-11-13 21:10:38 +0100 |
commit | 771646a2b36534fa120183a6ca221df86a0666c9 (patch) | |
tree | c224422f95a85dc68efcc94396b1415134f57afc | |
parent | 940e177437a1bb5b8afdc7d6f750401f52d78d94 (diff) | |
download | abrechenbarkeit-771646a2b36534fa120183a6ca221df86a0666c9.tar abrechenbarkeit-771646a2b36534fa120183a6ca221df86a0666c9.tar.bz2 abrechenbarkeit-771646a2b36534fa120183a6ca221df86a0666c9.tar.zst |
inactive users
-rwxr-xr-x | abrechenbarkeit.lua | 16 | ||||
-rw-r--r-- | locale/en.ini | 1 |
2 files changed, 14 insertions, 3 deletions
diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua index 61e4d3c..abce81e 100755 --- a/abrechenbarkeit.lua +++ b/abrechenbarkeit.lua @@ -324,7 +324,7 @@ local function get_active_users() table.insert(users, user) end - table.sort(users, function(a, b) return ((a.time == b.time) and a.name > b.name) or (a.time > b.time) end) + table.sort(users, function(a, b) return ((a.time == b.time) and a.name > b.name) or (a.time > b.time) end) return users end @@ -544,9 +544,10 @@ local function r_users(show_special) end print([[<div class="userlist"></div>]]) -- for printing print([[<ul class="userlist">]]) - for _, user in ipairs(get_active_users()) do + local show_user = function(user) local is_spu = user.name:sub(1, 1) == "@" - if is_spu == show_special then + local filter_out = query.prefix ~= nil and user.name:sub(1,1) ~= query.prefix + if is_spu == show_special and not filter_out then print(format([[<li> <a href="/{username_url}"> <span class="name">{!username}</span> @@ -559,7 +560,16 @@ local function r_users(show_special) })) end end + local inactive_cutoff = os.time() - (tonumber(config.inactive_cutoff) or (30 * 24 * 60 * 60)) + for _, user in ipairs(get_active_users()) do + if user.time > inactive_cutoff then show_user(user) end + end print("</ul>") + print(format([[<details><summary>{+users.inactive_list}</summary><ul class="userlist">]])) + for _, user in ipairs(get_active_users()) do + if user.time <= inactive_cutoff then show_user(user) end + end + print([[</ul></details>]]) end) end diff --git a/locale/en.ini b/locale/en.ini index 6b77621..44cf1e7 100644 --- a/locale/en.ini +++ b/locale/en.ini @@ -66,3 +66,4 @@ error.invalid_price=Price invalid error.invalid_name=Name invalid error.open_products=Failed to open products file error.no_path=No path +users.inactive_list=Inactive Users |