((by SublimeText.Mediawiker)) |
((by SublimeText.Mediawiker)) |
||
Line 59: | Line 59: | ||
'PI.FileName', |
'PI.FileName', |
||
}, |
}, |
||
− | oneToMany = { |
+ | -- oneToMany = { |
− | groupBy = { 'Image', 'AllName', 'FileName', 'IsCurrent' }, |
+ | -- groupBy = { 'Image', 'AllName', 'FileName', 'IsCurrent' }, |
− | fields = { |
+ | -- fields = { |
− | Teams = { |
+ | -- Teams = { |
− | 'CONCAT(CASE WHEN Ten.IsCurrent="1" THEN Ten.Team ELSE "" END)=TenureTeam', |
+ | -- 'CONCAT(CASE WHEN Ten.IsCurrent="1" THEN Ten.Team ELSE "" END)=TenureTeam', |
− | } |
+ | -- } |
− | } |
+ | -- } |
− | }, |
+ | --}, |
orderBy = 'Ten.IsCurrent DESC, COALESCE(PI.SortDate, T.Date) DESC, PR.AllName DESC', |
orderBy = 'Ten.IsCurrent DESC, COALESCE(PI.SortDate, T.Date) DESC, PR.AllName DESC', |
||
} |
} |
Revision as of 12:38, 29 June 2021
Documentation for this module may be created at Module:LFG/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_title = require("Module:TitleUtil")
local util_vars = require("Module:VarsUtil")
local i18n = require("Module:I18nUtil")
local ROWS = { 'Name', 'Country', 'Birthdate', 'Residency', 'Role' }
local h = {}
local p = {}
function p.main(frame)
local args = util_args.merge()
i18n.init('LFG')
if args.type:lower() == "duo" then
type = "Duo"
elseif args.type:lower() == "trio" then
type = "Trio"
end
local data = h.queryPlayers(type)
h.formatData(data)
return h.makeOutput(data)
end
function h.queryPlayers(lfg_type)
local query = {
tables = {
'Players=P',
'PlayerRedirects=PR',
'PlayerImages=PI',
'Tournaments=T',
'Tenures=Ten',
},
join = {
'P.OverviewPage=PR.OverviewPage',
'PR.AllName=PI.Link',
'PI.Tournament=T.OverviewPage',
'P.OverviewPage=Ten.NameLeave',
},
where = {
('P.IsLookingFor%s'):format(lfg_type),
'PI.IsProfileImage IS NULL OR PI.IsProfileImage="1"',
},
fields = {
'P.ID',
'P.Name',
'COALESCE(P.Nationality, P.Country)=Country [country]',
'P.Birthdate',
'P.Residency',
'P.Role',
'P.Team',
'PR.AllName',
'COALESCE(P.Image, PI.FileName)=Image',
'Ten.IsCurrent',
'PI.FileName',
},
-- oneToMany = {
-- groupBy = { 'Image', 'AllName', 'FileName', 'IsCurrent' },
-- fields = {
-- Teams = {
-- 'CONCAT(CASE WHEN Ten.IsCurrent="1" THEN Ten.Team ELSE "" END)=TenureTeam',
-- }
-- }
--},
orderBy = 'Ten.IsCurrent DESC, COALESCE(PI.SortDate, T.Date) DESC, PR.AllName DESC',
}
util_cargo.logQuery(query)
return query
end
function h.formatData(data)
if data.Country then
data.Country = data.Country:flair()
end
end
function h.makeOutput(data)
local boxes = mw.html.create('div')
:addClass('inline-content')
local box = boxes
for _, player in ipairs(data) do
local output = mw.html.create('div')
:addClass('tippingover-tooltip')
:addClass('tooltip-div')
:addClass('player-tooltip')
h.printImage(output, player.Image)
h.printRight(output, player)
h.printBottom(output, player)
tbl:tag('div'):addClass('inline-content')
end
tbl:tag('div'):attr('style', 'clear:left;')
return output
end
function h.printRight(output, data)
local div = output:tag('div')
:addClass('player-tooltip-info')
h.printPlayer(div, data)
h.printInfo(div, data)
end
function h.printPlayer(output, data)
output:tag('div')
:addClass('player-tooltip-player')
:wikitext(data.ID)
end
function h.printImage(output, image)
if not image or image == 'Unknown Infobox Image - Player.png' then return end
output:tag('div')
:addClass('player-tooltip-image')
:wikitext(('[[File:%s|250x200px|link=]]'):format(image))
end
function h.printInfo(div, data)
local tbl = div:tag('table')
:addClass('player-tooltip-info-table')
util_html.printVerticalData(tbl, data, ROWS)
end
function h.printBottom(div, data)
local ret = {
tables = { 'Tournaments=T', 'TournamentResults=Res', 'PlayerRedirects=PR' },
fields = { 'PRPoints' },
join = 'T._pageName = Res.OverviewPage, Res.RosterLinks HOLDS PR.AllName',
where = h.getWhere(data.ID),
types = {
PRPoints = 'number'
}
}
end
function h.getWhere(data)
local tbl = {
('PR._pageName="%s"'):format(data.ID),
'Res.RosterLinks HOLDS PR.AllName',
'T.Date >= "2018-01-01" AND T.Date <= "2021-12-31"'
}
return util_cargo.concatWhere(tbl)
end
return p