add maximum url parameter; document special list in readme

This commit is contained in:
Riley L. 2024-11-20 21:59:27 +01:00
parent 5ec847be56
commit 80cf5a6ccd
2 changed files with 9 additions and 4 deletions

View file

@ -584,7 +584,7 @@ local function r_users(show_special, filter_negative)
local is_spu = user.name:sub(1, 1) == "@" 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 (filter_negative ~= nil and user.balance < filter_negative) if (filter_negative ~= nil and user.balance < filter_negative)
or (filter_negative == nil and is_spu == show_special and not filter_out) then or (filter_negative == nil and is_spu == show_special and (not filter_out)) then
print(format([[<li> print(format([[<li>
<a href="/{username_url}"> <a href="/{username_url}">
<span class="name">{!username}</span> <span class="name">{!username}</span>
@ -599,9 +599,10 @@ local function r_users(show_special, filter_negative)
end end
local inactive_cutoff = os.time() - (tonumber(config.inactive_cutoff) or (30 * 24 * 60 * 60)) local inactive_cutoff = os.time() - (tonumber(config.inactive_cutoff) or (30 * 24 * 60 * 60))
for _, user in ipairs(get_active_users()) do for _, user in ipairs(get_active_users()) do
if user.time > inactive_cutoff then show_user(user) end if filter_negative or user.time > inactive_cutoff then show_user(user) end
end end
print("</ul>") print("</ul>")
if filter_negative ~= nil then return end
print(format([[<details><summary>{+users.inactive_list}</summary><ul class="userlist">]])) print(format([[<details><summary>{+users.inactive_list}</summary><ul class="userlist">]]))
for _, user in ipairs(users) do for _, user in ipairs(users) do
if user.time <= inactive_cutoff then show_user(user) end if user.time <= inactive_cutoff then show_user(user) end
@ -802,8 +803,7 @@ if path == "/" then
elseif query.users and query.export then elseif query.users and query.export then
return r_export_balances() return r_export_balances()
else else
return r_users(false, query.negative) return r_users(false, query.negative and (query.maximum or 0))
-- tonumber(query.negative or 0) or nil)
end end
else else
local username = extract_username() local username = extract_username()

View file

@ -23,3 +23,8 @@ useful for development or proxyless deployments.
curl 'http://strichliste.example.org/api/user?deleted=false' | jq -r '.users.[] | [ 0, "@Potential", .name, .balance, "", "", "" ] | join(",")' > log curl 'http://strichliste.example.org/api/user?deleted=false' | jq -r '.users.[] | [ 0, "@Potential", .name, .balance, "", "", "" ] | join(",")' > log
curl 'http://strichliste.example.org/api/article' | jq -r '.articles.[] | [ .barcode, .amount, "@Drinks", .name ] | join(",")' > products curl 'http://strichliste.example.org/api/article' | jq -r '.articles.[] | [ .barcode, .amount, "@Drinks", .name ] | join(",")' > products
``` ```
## Non-linked User lists
- list of Users with negative balance: `http://abrechenbarkeit.example.org/?negative`
- list of Users with balance lower than <amount>: `http://abrechenbarkeit.example.org/?negative&maximum=<amount>`