Module:PROverview

local m_text = require('Module:Text') local util = require('Module:Util')

local p = {} function p.main(frame) if frame == mw.getCurrentFrame then args = require('Module:ProcessArgs').merge(true) else frame = mw.getCurrentFrame end local thisteam = args[1] or mw.title.getCurrentTitle.rootText local result = mw.ext.cargo.query('PowerRankings', 'Date,Teams__full=Teams,URL', {		where = 'Teams HOLDS "' .. thisteam .. '"',		orderBy = 'Date'	}) local places = {} for _, row in ipairs(result) do		teams = m_text.split(row.Teams,'%s*,%s*') for k, v in ipairs(teams) do			if v == thisteam then if places[k] then places[k][#places[k]+1] = { date = row.Date, url = row.URL } else places[k] = { { date = row.Date, url = row.URL } } end break end end end local text = {} for i = 1, 10 do		if places[i] then text[#text+1] = string.format("%s-place rankings: %s (", util.serializeNumber(i), #places[i] )			list = {}			for k, v in ipairs(places[i]) do				list[#list+1] = string.format( ' [%s %s] ', v.url or '', v.date or '' )			end			text[#text+1] = table.concat(list, ' &#8226; ')			text[#text+1] = ') ' end end text[#text+1] = string.format("Click here for a full list of all included power rankings.", thisteam) local output = table.concat(text,'') return output end return p