diff options
author | Riley L. <riley@e926.de> | 2024-11-20 21:13:26 +0100 |
---|---|---|
committer | Riley L. <riley@e926.de> | 2024-11-20 21:13:26 +0100 |
commit | 5ec847be563709737d5ff8b0fbff88678b2c67c4 (patch) | |
tree | 3eae9b75231d883b4f3aafaf440ff38f1bf5d174 | |
parent | a4292166397b6ef40cd7af2110b7acaf009b9b10 (diff) | |
download | abrechenbarkeit-5ec847be563709737d5ff8b0fbff88678b2c67c4.tar abrechenbarkeit-5ec847be563709737d5ff8b0fbff88678b2c67c4.tar.bz2 abrechenbarkeit-5ec847be563709737d5ff8b0fbff88678b2c67c4.tar.zst |
add filtering for users with balance below threshold
-rwxr-xr-x | abrechenbarkeit.lua | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua index f5b48a0..b7636a1 100755 --- a/abrechenbarkeit.lua +++ b/abrechenbarkeit.lua @@ -530,7 +530,11 @@ local function r_log(filter) end) end -local function r_users(show_special) +local function r_users(show_special, filter_negative) + if filter_negative ~= nil then + filter_negative = tonumber(filter_negative) or 0 + end + return respond(200, "Abrechenbarkeit", function() local users = get_active_users() @@ -579,7 +583,8 @@ local function r_users(show_special) local show_user = function(user) local is_spu = user.name:sub(1, 1) == "@" local filter_out = query.prefix ~= nil and user.name:sub(1, 1):lower() ~= query.prefix - if is_spu == show_special and not filter_out then + if (filter_negative ~= nil and user.balance < filter_negative) + or (filter_negative == nil and is_spu == show_special and not filter_out) then print(format([[<li> <a href="/{username_url}"> <span class="name">{!username}</span> @@ -793,15 +798,12 @@ if path == "/" then elseif query.create_user then return r_create_user() elseif query.spus then - return r_users(true) - elseif query.users then - if query.export then - return r_export_balances() - else - return r_users(false) - end + return r_users(true, nil) + elseif query.users and query.export then + return r_export_balances() else - return r_users(false) + return r_users(false, query.negative) + -- tonumber(query.negative or 0) or nil) end else local username = extract_username() |