5,478
edits
mNo edit summary |
No edit summary |
||
Line 64: | Line 64: | ||
local results = cargo.query('Album_Songs', table.concat(fields, ','), query) | local results = cargo.query('Album_Songs', table.concat(fields, ','), query) | ||
local | local groups = {} | ||
for _, result in ipairs(results) do | |||
for _, | local singers = mw.text.split(result.singers, ",") | ||
local singers = mw.text.split( | |||
local type = nil | local type = nil | ||
if | if result.type == "solover" then | ||
type = "'''" .. horseName .. " ver.'''" | type = "'''" .. horseName .. " ver.'''" | ||
elseif #singers == 1 then | elseif #singers == 1 then | ||
type = "'''Solo'''" | type = "'''Solo'''" | ||
elseif not | elseif not result.type then | ||
type = "Group" | type = "Group" | ||
end | end | ||
if type ~= nil then | if type ~= nil then | ||
table.insert( | if not groups[result.song_title] then groups[result.song_title] = {} end | ||
table.insert(groups[result.song_title], { album = result.album, type = type }) | |||
end | end | ||
end | end | ||
local text = '{| class="wikitable sortable mw-collapsible"\n! Song !! Album !! Type\n' | local text = '{| class="wikitable sortable mw-collapsible"\n! Song !! Album !! Type\n' | ||
for | for song, rows in ipairs(groups) do | ||
local rowspan = #rows | |||
local head = table.remove(rows, 1) | |||
text = text .. | text = text .. | ||
string.format('|-\n| rowspan=%d|[[%s]] || [[%s]] || %s\n', | string.format('|-\n| rowspan=%d|[[%s]] || [[%s]] || %s\n', rowspan, song, head.album, head.type) | ||
for _, row in ipairs(rows) do | |||
text = text .. | |||
string.format('|-\n| [[%s]] || %s\n', row.album, row.type) | |||
end | |||
end | end | ||
text = text .. '|}' | text = text .. '|}' |