Module:Mine Religion

require "Module:Database Miner" require "Module:Demographics Basics" require "Module:Demographics Database" require "Module:FormatNum"

function mineout(tabula,race) local database = {} database[race] = MineDatabase(tabula,race) return generate(database,race,"Religion") end local p = require( 'Module:Demographics/PopQuery' )

function generate_infobox_data(race,l) local function groupByCountry(pop) return pop['area']['region']['country']['countryName'] end local temp = "" local database = p.query(groupByCountry, 0, race, 0, 0, 0, 0, 0, 0) local sortedKeys = getKeysSortedByValue(database, function(a, b) return a > b end) local i = l   for _, key in ipairs(sortedKeys) do        temp = temp .. "|region" .. i .. " = \n" temp = temp .. "|pop" .. i .. " = c. '''" .. format_num(database[key],0) .. "'''\n" i = i + 1 end return temp end

function generate_infobox_markup(race,l) local database = {} local args = {} local temp = "" database[race] = MineDatabase(demographics.religion,race) local total = total_table(database,race) args["population"] = "c. '''" .. format_num(total,0) .. "'''"   local sortedKeys = getKeysSortedByValue(database[race], function(a, b) return a > b end) local i = l   for _, key in ipairs(sortedKeys) do temp = "region" .. i       args[temp]  = "" temp = "pop" .. i       args[temp] = "c. '''" .. format_num(database[race][key],0) .. "'''"       i = i + 1 end return args end

function generate_infobox_markup_hu(race,l) local database = {} local args = {} local temp = "" database[race] = MineDatabase(demographics.religion,race) local total = total_table(database,race) args["population"] = "c. '''" .. format_num(total,0) .. "'''"   local sortedKeys = getKeysSortedByValue(database[race], function(a, b) return a > b end) local i = l   for _, key in ipairs(sortedKeys) do temp = "region" .. i       args[temp]  = "" temp = "pop" .. i       args[temp] = "c. '''" .. format_num(database[race][key],0) .. "'''"       i = i + 1 end return args end

function p.main(frame) return mineout(demographics.religion,frame.args[1]) end function p.infobox(frame) return frame:expandTemplate{title = 'Infobox religious group',generate_infobox_markup(frame.args[1],frame.args[2])} end return p