.mw-parser-output .documentation,.mw-parser-output .documentation-metadata{border:1px solid var(--border-color-base,#a2a9b1);background-color:#ecfcf4;color:inhe
local p = {}
function p.sums()
local function add_days_to_date(date_str, days)
local y, m, d = date_str:match("(%d+)%-(%d+)%-(%d+)")
local ts = os.time{ year = y, month = m, day = d, hour = 12 }
local new_ts = ts + days * 24 * 60 * 60
return os.date("%Y-%m-%d", new_ts)
end
-- Initialise language
local lang = mw.language.getContentLanguage()
-- Load the data array
-- https://commons.wikimedia.org/wiki/Data:URAstats_Data.tab
local t = mw.ext.data.get('URAstats_Data.tab')
local rows = t.data
-- get the necessary rows
local day0 = rows[#rows] -- today
local day1 = rows[#rows-1] -- yesterday
local dayz = rows[1] -- when records began
-- Extract numeric fields (columns 2–6)
local a0 = tonumber(day0[2]) or 0
local b0 = tonumber(day0[3]) or 0
local c0 = tonumber(day0[4]) or 0
local d0 = tonumber(day0[5]) or 0
local e0 = tonumber(day0[6]) or 0
local a1 = tonumber(day1[2]) or 0
local b1 = tonumber(day1[3]) or 0
local c1 = tonumber(day1[4]) or 0
local d1 = tonumber(day1[5]) or 0
local e1 = tonumber(day1[6]) or 0
local az = tonumber(dayz[2]) or 0
local bz = tonumber(dayz[3]) or 0
local cz = tonumber(dayz[4]) or 0
local dz = tonumber(dayz[5]) or 0
local ez = tonumber(dayz[6]) or 0
-- Compute sums
local def0 = a0 + b0 + c0
local prob0 = d0 + e0
local def1 = a1 + b1 + c1
local prob1 = d1 + e1
local defz = az + bz + cz
local probz = dz + ez
-- Compute rate
local articles_per_day = math.floor((((defz + probz) - (def0 + prob0)) / #rows))
local days_to_clear_backlog = math.ceil(((def0 + prob0) / articles_per_day))
-- Retrieve dates and format them nicely
local date0 = lang:formatDate( "j F Y", day0[1], nil )
local finish_date = lang:formatDate( "j F Y", add_days_to_date(day0[1], days_to_clear_backlog), nil)
-- Compose return string
return string.format(
"At the beginning of the day (UTC) on %s there were:\n" ..
"* %s tagged unreferenced articles, a change of %s since the day before\n" ..
"* %s probably unreferenced articles, a change of %s since the day before\n" ..
"* That is, a '''total backlog of %s articles''' still to deal with, a change of %s since the day before\n" ..
"At the current [[arithmetic mean|average]] rate of '''%s articles per day''', " ..
"it will take '''%s days to clear the backlog''', " ..
"finishing on '''%s'''.",
date0,
lang:formatNum(def0), lang:formatNum(def0 - def1),
lang:formatNum(prob0), lang:formatNum(prob0 - prob1),
lang:formatNum(def0 + prob0), lang:formatNum((def0 + prob0) - (def1 + prob1)),
lang:formatNum(articles_per_day), lang:formatNum(days_to_clear_backlog), finish_date
)
end
return p
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.