make update script quiet

This commit is contained in:
nein.wtf 2022-02-21 22:20:54 +01:00
commit 384fcad395
3 changed files with 15 additions and 7 deletions

View file

@ -1,6 +1,8 @@
sqlite3 = require "lsqlite3" sqlite3 = require "lsqlite3"
db = sqlite3.open('covid_deaths.db') db = sqlite3.open('covid_deaths.db', sqlite3.OPEN_READONLY)
SetStatus(200)
SetHeader('Content-Type', 'text/html; charset=utf-8')
Write([[ Write([[
<!doctype html> <!doctype html>
<html> <html>
@ -14,6 +16,10 @@ Write([[
padding: 48px; padding: 48px;
font-family: sans-serif; font-family: sans-serif;
color: #222; color: #222;
word-break: break-all;
}
p {
word-break: normal;
} }
span.last-update { span.last-update {
color: #999; color: #999;
@ -51,11 +57,11 @@ end
local deaths_yesterday = rows[1]["sum_deaths"] - rows[2]["sum_deaths"] 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. ' local description = format_int(rows[1]["sum_deaths"]) .. ' people died from Covid-19. ' .. format_int(deaths_yesterday) .. ' died within the last day. '
Write('<p>' .. description .. ' <span class="last-update">Last update: ' .. rows[1]["last_update"] .. ' UTC</span></p>') Write('<p>' .. description .. ' <span class="last-update">Last update: ' .. rows[1]["last_update"] .. ' UTC (<a href="https://github.com/CSSEGISandData/COVID-19/tree/master/csse_covid_19_data" target="_blank">Source</a>)</span></p>')
Write('<span class="count">') Write('<span class="count">')
for i=1,rows[1]["sum_deaths"] do for i=1,rows[1]["sum_deaths"] do
Write('🖤') Write('')
if i > 0 and i < rows[1]["sum_deaths"] and i % 100 == 0 then if i > 0 and i < rows[1]["sum_deaths"] and i % 100 == 0 then
Write('</span><span class="count">') Write('</span><span class="count">')
end end

Binary file not shown.

View file

@ -1,10 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex # set -ex
curl 'https://covid-19.datasettes.com/covid.csv?sql=select+day%2C+last_update%2C+sum(deaths)+sum_deaths%0D%0Afrom+johns_hopkins_csse_daily_reports%0D%0Awhere+country_or_region+not+like+%27%25Olympics%25%27%0D%0Agroup+by+day%0D%0Aorder+by+day+desc%0D%0Alimit+7%0D%0A&_header=off' > covid_deaths.csv && \ cd $(dirname $0) && \
curl -fsS 'https://covid-19.datasettes.com/covid.csv?sql=select+day%2C+last_update%2C+sum(deaths)+sum_deaths%0D%0Afrom+johns_hopkins_csse_daily_reports%0D%0Awhere+country_or_region+not+like+%27%25Olympics%25%27%0D%0Agroup+by+day%0D%0Aorder+by+day+desc%0D%0Alimit+7%0D%0A&_header=off' > covid_deaths.csv && \
./sqlite3.com covid_deaths.db \ ./sqlite3.com covid_deaths.db \
'pragma journal_mode = "wal"' \ 'pragma journal_mode = "wal"' \
'create table if not exists covid_deaths(day text, last_update text, sum_deaths integer)' \ 'create table if not exists covid_deaths(day text, last_update text, sum_deaths integer)' \
'create index if not exists covid_deaths_by_day on covid_deaths (day)' \
'.mode csv' \ '.mode csv' \
'.import covid_deaths.csv covid_deaths' \ '.import covid_deaths.csv covid_deaths' \
'delete from covid_deaths where rowid not in ( select max(rowid) from covid_deaths group by day )' 'delete from covid_deaths where rowid not in ( select max(rowid) from covid_deaths group by day )' > /dev/null