Module:Songs: Difference between revisions
Jump to navigation
Jump to search
no edit summary
mNo edit summary |
No edit summary |
||
Line 50: | Line 50: | ||
end | end | ||
return text | return text | ||
end | |||
local function songrepeated(results) | |||
local counts = {} | |||
for _, row in ipairs(results) do | |||
if row.song_title and row.song_title ~= "" and not string.find(row.song_title, "% Size%)") and not string.find(row.song_title, "% Remix%)") then | |||
counts[row.song_title] = (counts[row.song_title] or 0) + 1 | |||
end | |||
end | |||
return counts | |||
end | end | ||
Line 63: | Line 73: | ||
local fields = {'song_title', 'album', 'type'} | local fields = {'song_title', 'album', 'type'} | ||
local results = cargo.query('Album_Songs', table.concat(fields, ','), query) | local results = cargo.query('Album_Songs', table.concat(fields, ','), query) | ||
local songnumber = songrepeated(results) | |||
local table = '{| class="wikitable sortable mw-collapsible"\n! Song !! Album !! Type\n' | local table = '{| class="wikitable sortable mw-collapsible"\n! Song !! Album !! Type\n' | ||
local checked = {} | |||
for _, row in ipairs(results) do | for _, row in ipairs(results) do | ||
if row.song_title and row.song_title ~= "" and not string.find(row.song_title, "% Size%)") and not string.find(row.song_title, "% Remix%)") then | if row.song_title and row.song_title ~= "" and not string.find(row.song_title, "% Size%)") and not string.find(row.song_title, "% Remix%)") then | ||
Line 76: | Line 89: | ||
type = "Group" | type = "Group" | ||
end | end | ||
table = table .. '|-\n| [[' .. row.song_title .. ']] || [[' .. row.album .. ']] || ' .. type .. '\n' | local count = songnumber[row.song_title] | ||
if count > 1 then | |||
if not checked[row.song_title] then | |||
table = table .. '|-\n| rowspan="' .. count .. '" | [[' .. row.song_title .. ']] || [[' .. row.album .. ']] || ' .. type .. '\n' | |||
checked[row.song_title] = true | |||
else | |||
table = table .. '|-\n| [[' .. row.album .. ']] || ' .. type .. '\n' | |||
end | |||
else | |||
table = table .. '|-\n| [[' .. row.song_title .. ']] || [[' .. row.album .. ']] || ' .. type .. '\n' | |||
end | |||
end | end | ||
end | end |