mirror of
https://codeberg.org/metamuffin/abrechenbarkeit.git
synced 2025-02-23 03:21:41 +00:00
format time in logo
This commit is contained in:
parent
f71092470d
commit
9f453051c7
1 changed files with 15 additions and 23 deletions
|
@ -167,30 +167,21 @@ local function last_txns()
|
|||
end
|
||||
|
||||
local function get_active_users()
|
||||
local user_balances = {}
|
||||
local user_balances = {}
|
||||
for time, username, amount, _, _, _ in read_log() do
|
||||
user_balances[username] = {
|
||||
time = time,
|
||||
username = username,
|
||||
balance = (user_balances[username] or {balance = 0}).balance + amount
|
||||
time = time,
|
||||
username = username,
|
||||
balance = (user_balances[username] or { balance = 0 }).balance + amount
|
||||
}
|
||||
end
|
||||
|
||||
local users = {}
|
||||
for _, user in pairs(user_balances) do
|
||||
table.insert(users, user)
|
||||
end
|
||||
|
||||
table.sort(users, function(a,b) return a.time > b.time end)
|
||||
for k, user in pairs(users) do
|
||||
io.stderr:write(string.format("%s %s %s %s\n",
|
||||
k,
|
||||
os.date("!%Y-%m-%dT%H:%M:%SZ", user.time),
|
||||
user.username,
|
||||
user.balance
|
||||
))
|
||||
end
|
||||
local users = {}
|
||||
for _, user in pairs(user_balances) do
|
||||
table.insert(users, user)
|
||||
end
|
||||
|
||||
table.sort(users, function(a, b) return a.time > b.time end)
|
||||
return users
|
||||
end
|
||||
|
||||
|
@ -210,7 +201,8 @@ local function r_user_post(username)
|
|||
pcount = (tonumber(data.pcount) or 1) * (data.negate_pcount ~= nil and -1 or 1)
|
||||
pcode = p_barcode
|
||||
if amount == nil then amount = pcount * p_amount end
|
||||
if comment == nil then comment = string.format("%s %d %s", pcount < 0 and "Buy" or "Restock", math.abs(pcount), p_name) end
|
||||
if comment == nil then comment = string.format("%s %d %s", pcount < 0 and "Buy" or "Restock",
|
||||
math.abs(pcount), p_name) end
|
||||
end
|
||||
end
|
||||
if amount == nil then
|
||||
|
@ -331,7 +323,7 @@ local function r_log(filter)
|
|||
if filter == nil or filter == username then
|
||||
print(string.format([[
|
||||
<tr>
|
||||
<td>%d (%s ago)</td>
|
||||
<td>%s (%s ago)</td>
|
||||
<td>%s</td>
|
||||
<td class="amount-%s">%.02f€</td>
|
||||
<td>%s</td>
|
||||
|
@ -346,7 +338,7 @@ local function r_log(filter)
|
|||
</td>
|
||||
</tr>
|
||||
]],
|
||||
time, format_duration(os.time() - time),
|
||||
os.date("!%Y-%m-%dT%H:%M:%SZ", time), format_duration(os.time() - time),
|
||||
escape(username),
|
||||
amount >= 0 and "pos" or "neg", amount / 100,
|
||||
escape(pcode) or "",
|
||||
|
|
Loading…
Add table
Reference in a new issue