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([[
  • {!username} @@ -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()