From fb6eafaec0581b4754ae99a7a719e3e9b40a6106 Mon Sep 17 00:00:00 2001 From: "Riley L." Date: Wed, 20 Nov 2024 22:34:56 +0100 Subject: [PATCH] style negative user list; add embezzlement amount --- abrechenbarkeit.lua | 33 +++++++++++++++++++++++++++------ locale/en.ini | 1 + style.css | 4 ++-- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua index b7ec392..41b4e8f 100755 --- a/abrechenbarkeit.lua +++ b/abrechenbarkeit.lua @@ -540,7 +540,7 @@ local function r_users(show_special, filter_negative) if not show_special then print(format([[ -
+

{+index.form.create_user}

@@ -583,8 +583,9 @@ local function r_users(show_special, filter_negative) 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 (filter_negative ~= nil and user.balance < filter_negative) - or (filter_negative == nil and is_spu == show_special and (not filter_out)) then + if is_spu == show_special and + ((filter_negative ~= nil and user.balance < filter_negative) + or (filter_negative == nil and (not filter_out))) then print(format([[
  • {!username} @@ -597,12 +598,32 @@ local function r_users(show_special, filter_negative) })) end end + + if filter_negative ~= nil then + table.sort(users, function(a, b) + return a.balance < b.balance + 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 filter_negative or user.time > inactive_cutoff then show_user(user) end + local embezzlement = 0 + for _, user in ipairs(users) do + if filter_negative or user.time > inactive_cutoff then + show_user(user) + + if user.name:sub(1,1) ~= "@" then + if user.balance < 0 then embezzlement = embezzlement - user.balance end + end + end end print("") - if filter_negative ~= nil then return end + if filter_negative ~= nil then + print(format([[
    {+users.embezzlement}
    ]], { + amount = format_amount(embezzlement) + })) + + return + end print(format([[
    {+users.inactive_list}
      ]])) for _, user in ipairs(users) do if user.time <= inactive_cutoff then show_user(user) end diff --git a/locale/en.ini b/locale/en.ini index e12704c..98dffee 100644 --- a/locale/en.ini +++ b/locale/en.ini @@ -68,3 +68,4 @@ error.invalid_name=Name invalid error.open_products=Failed to open products file error.no_path=No path users.inactive_list=Inactive Users +users.embezzlement=A total of {amount} are currently under embezzlement. diff --git a/style.css b/style.css index e3ddc27..9599c84 100644 --- a/style.css +++ b/style.css @@ -97,11 +97,11 @@ nav> :last-child { } /* landing page */ -form#user_creation { +.section { background-color: var(--b2); padding: 1em; margin-top: 2em; - border-radius: 4px; + border-radius: 4px; } form#user_creation>h3 {