Leaguepedia | League of Legends Esports Wiki
Advertisement
Leaguepedia | League of Legends Esports Wiki

Documentation for this module may be created at Module:TeamProfileGallery/doc

local util_args = require('Module:ArgsUtil')
local util_cargo = require("Module:CargoUtil")
local util_html = require("Module:HtmlUtil")
local util_map = require('Module:MapUtil')
local util_table = require("Module:TableUtil")
local util_text = require("Module:TextUtil")
local util_vars = require("Module:VarsUtil")
local i18n = require("Module:I18nUtil")
local lang = mw.getLanguage('en')
local Gallery = require('Module:GalleryClass')

local h = {}
local p = {}

function p.main(frame)
	local args = util_args.merge()
	local images = h.makeAndRunQuery(args)
	return Gallery(images):run()
end
function h.makeAndRunQuery(args)
	local query = h.getQuery(args)
	return util_cargo.queryAndCast(query)
end

function h.getQuery(args)
	local query = {
		tables = {
			'TeamRedirects=TR',
			'TeamRosterPhotos=TP',
			'Tournaments=T',
		},
		join = {
			'TR.AllName=TP.Team',
			'TP.Tournament=T.OverviewPage',
		},
		where = h.getWhere(args),
		fields = { 'TP.FileName', 'TP.Caption' },
		orderBy = 'COALESCE(TP.SortDate, T.DateStartFuzzy, T.Date)',
	}
	util_cargo.logQuery(query)
	return query
end

function h.getWhere(args)
	local where = {
		('TR._pageName="%s"'):format(args.team),
		('TP._pageName IS NOT NULL'),
	}
	return where
end

return p
Advertisement