Module:Today in history

local p = {} local cargo = mw.ext.cargo

function p._releases(month, day) if date_input == nil then date_sql = 'MONTH(release_date) = MONTH(NOW) AND DAYOFMONTH(release_date) = DAYOFMONTH(NOW)' else date_sql = 'MONTH(release_date) = "' .. month .. '" AND DAYOFMONTH(release_date) = "' .. day .. '"' end

local results = cargo.query(		'releases',		'_pageName=subject, release_date, country, format',		{			where = date_sql,			orderBy = 'release_date ASC'		}	)

local releases_by_subject = {} for r = 1, #results do		local subject = results[r]['subject'] local country = results[r]['country'] local format_ = results[r]['format']

if releases_by_subject[subject] == nil then releases_by_subject[subject] = { [country] = { format_ } }		else if releases_by_subject[subject][country] == nil then releases_by_subject[subject][country] = { format_ } else table.insert(releases_by_subject[subject][country], format_) end end end

mw.logObject(releases_by_subject) end

return p