Dimensions of Covid
]])
local query = [[
SELECT day, last_update, sum_deaths
FROM covid_deaths
ORDER BY day DESC
LIMIT 2
]]
local rows = {}
for v in db:nrows(query) do
rows[#rows + 1] = v
end
-- taken from http://lua-users.org/wiki/FormattingNumbers, thanks!
function format_int(number)
local formatted = number
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1 %2')
if (k==0) then
break
end
end
return formatted
end
local deaths_yesterday = rows[1]["sum_deaths"] - rows[2]["sum_deaths"]
local description = format_int(rows[1]["sum_deaths"]) .. ' people died from Covid-19. ' .. format_int(deaths_yesterday) .. ' died within the last day. '
Write('
' .. description .. ' Last update: ' .. rows[1]["last_update"] .. ' UTC (Source)
')
Write('')
for i=1,rows[1]["sum_deaths"] do
Write('•')
if i > 0 and i < rows[1]["sum_deaths"] and i % 100 == 0 then
Write('')
end
end
Write('')
Write([[
]])