diff options
author | metamuffin <metamuffin@disroot.org> | 2024-11-13 23:44:48 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-11-13 23:45:29 +0100 |
commit | a4292166397b6ef40cd7af2110b7acaf009b9b10 (patch) | |
tree | 511c237b7c7b4dc60cfc420287c53cf0addab904 | |
parent | e15528223475f166db61b690e41597544425933a (diff) | |
download | abrechenbarkeit-a4292166397b6ef40cd7af2110b7acaf009b9b10.tar abrechenbarkeit-a4292166397b6ef40cd7af2110b7acaf009b9b10.tar.bz2 abrechenbarkeit-a4292166397b6ef40cd7af2110b7acaf009b9b10.tar.zst |
export balances
-rwxr-xr-x | abrechenbarkeit.lua | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua index 12514d2..f5b48a0 100755 --- a/abrechenbarkeit.lua +++ b/abrechenbarkeit.lua @@ -578,7 +578,7 @@ 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 + 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 print(format([[<li> <a href="/{username_url}"> @@ -766,6 +766,14 @@ local function r_export_products() print(l) end end +local function r_export_balances() + print("Status: 200") + print("Content-Type: text/csv") + print("") + for user, balance in pairs(balances()) do + print(string.format("%s,%d", user, balance)) + end +end if path == "/" then if query.about then @@ -787,7 +795,11 @@ if path == "/" then elseif query.spus then return r_users(true) elseif query.users then - return r_users(false) + if query.export then + return r_export_balances() + else + return r_users(false) + end else return r_users(false) end |