Module:Données de la pandémie de maladie à coronavirus de 2019-2020 en France/Bac à sable
La documentation de ce module est générée par le modèle {{Documentation module}}.
Les éditeurs peuvent travailler dans le bac à sable (modifier).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
local p = {}
local wd = require "Module:Wikidata"
local infotype = {
cases = "P1603",
recovered = "P8010",
deaths = "P1120",
survivors = "P1561",
}
local regions = {
{"[[Auvergne-Rhône-Alpes|ARA]]", "Q87143769"},
{"[[Bourgogne-Franche-Comté|BFC]]", "Q87144034"},
{"[[Région Bretagne|Bret.]]", "Q87144495"},
{"[[Centre-Val de Loire|CVdL]]", "Q87144085"},
{"[[Corse]]", "Q87144110"},
{"[[Grand Est|G.E.]]", "Q87144137"},
{"[[Hauts-de-France|HdF]]", "Q87144163"},
{"[[Île-de-France|ÎdF]]", "Q87144245"},
{"[[Normandie|Norm.]]", "Q87144265"},
{"[[Nouvelle-Aquitaine|N.Aq.]]", "Q87144289"},
{"|[[Occitanie (région administrative)|Occ.]]", "Q87144502"},
{"[[Pays de la Loire|PdlL]]", "Q87144323"},
{"[[Provence-Alpes-Côte d'Azur|PACA]]", "Q87144359"},
{"Guad.", "Q87144389"},
{"Guy."},
{"Mart."},
{"May."},
{"Nv. Cal."},
{"Poly."},
{"La R."},
{"St-B"},
{"St-M"},
{"St-P. M"},
{"W. et F."},
}
local function compute(what, when, regionnum)
local regionid = regions[regionnum][2]
if not regionid then
return nil
end
return wd.formatStatements{
entity = regionid,
property = infotype[what],
atdate = when,
numval = 1,
withdate = true
}
end
function p.main()
local box = mw.html.create('table')
:addClass("wikitable mw-collapsible")
:cssText("float:left; text-align:left;")
:tag("tr") -- ligne de titre
:tag("td")
:cssText("font-size:11pt;")
:tag("span")
:addClass("nowrap")
:wikitext("Cas de Covid-19 en France par région")
:done()
:done()
:done()
:tag("tr")
:tag("td")
:wikitext("")
:done()
:tag("td")
:attr("colspan", 13)
:wikitext("Métropole")
:done()
:tag("td")
:attr("colspan", 11)
:wikitext("Outremer")
:done()
:tag("td")
:attr("colspan", 2)
:attr("rowspan", 2)
:wikitext("Cas")
:done()
:tag("td")
:attr("colspan", 2)
:attr("rowspan", 2)
:wikitext("Décès")
:done()
:tag("td")
:attr("colspan", 2)
:attr("rowspan", 2)
:wikitext("Guéris à l'hôpital")
:done()
:done()
:tag("tr")
:tag("td")
:wikitext("Date")
:done()
--[[ for i, region in ipairs(regions) do
box:tag("td")
:attr("rowspan", 2)
:wikitext(region[1])
:done()
end
box:done() ]]
:done()
box:tag("tr")
:tag("td")
:wikitext("Nouv.")
:done()
:tag("td")
:wikitext("Nouv. %")
:done()
:tag("td")
:wikitext("Total")
:done()
:tag("td")
:wikitext("Nouv.")
:done()
:tag("td")
:wikitext("Nouv. %")
:done()
:tag("td")
:wikitext("Total")
:done()
:tag("td")
:wikitext("Nouv.")
:done()
:tag("td")
:wikitext("Nouv. %")
:done()
:tag("td")
:wikitext("Total")
:done()
:done()
-- ligne régions
-- dates à utiliser // à raffiner
local isodates = {}
local start = {year = 2020, month = 1, day = 24}
local ending= {year = 2020, month = 3, day = 30}
local monthlength = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
local current = start
while ( (current.month == ending.month) and (current.day <= ending.day) ) or (current.month < ending.month) do
local y, m, d = tostring(current.year), tostring(current.month), tostring(current.day)
if string.len(m) == 1 then m = "0" .. m end
if string.len(d) == 1 then d = "0" .. d end
table.insert(isodates, y .. "-" .. m .. "-" .. d)
if current.day >= monthlength[current.month] then
current.month = current.month + 1
current.day = 0
end
current.day = current.day + 1
end
local function getRow(t)
local row = mw.html.create('tr')
:tag("td")
:wikitext(t)
:done()
local totalcases = 0
for i, region in ipairs(regions) do
local num = compute("cases", t, i)
row:tag("td")
:wikitext(num)
:done()
if num and tonumber(num) then
totalcases = totalcases + tonumber(num)
end
end
row:tag('td')
:wikitext(totalcases)
:done()
return row
end
for i, t in ipairs(isodates) do
box:node(getRow(t))
end
box:allDone()
return tostring(box)
end
return p