Module:Songs: Difference between revisions

Jump to navigation Jump to search
1,029 bytes removed ,  Thursday at 00:56
no edit summary
mNo edit summary
No edit summary
Line 21: Line 21:
local text = ''
local text = ''
for _, ev in ipairs(events) do
for _, ev in ipairs(events) do
text = text .. frame:expandTemplate{
text = text .. frame:expandTemplate {
title='Song Albums/Entry',
title = 'Song Albums/Entry',
args=ev
args = ev
} .. '\n'
} .. '\n'
end
end
Line 38: Line 38:
orderBy = "event_order ASC, leg_order ASC, day ASC",
orderBy = "event_order ASC, leg_order ASC, day ASC",
}
}
local fields = {'event_page', 'leg_name', 'day', 'cast'}
local fields = { 'event_page', 'leg_name', 'day', 'cast' }
local events = cargo.query('Setlist_Event, Setlist_Songs',
local events = cargo.query('Setlist_Event, Setlist_Songs',
table.concat(fields, ','), query)
table.concat(fields, ','), query)
Line 44: Line 44:
local text = ''
local text = ''
for _, ev in ipairs(events) do
for _, ev in ipairs(events) do
text = text .. frame:expandTemplate{
text = text .. frame:expandTemplate {
title='Song Events/Entry',
title = 'Song Events/Entry',
args=ev
args = ev
} .. '\n'
} .. '\n'
end
end
Line 52: Line 52:
end
end


local function songrepeated(results)
function p.characterSongs(frame)
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
 
function p.songs(frame)
local horseName = mw.text.decode(frame.args[1])
local horseName = mw.text.decode(frame.args[1])
if not horseName then return end
if not horseName then return end
Line 71: Line 61:
orderBy = "Album_Songs.song_title ASC"
orderBy = "Album_Songs.song_title ASC"
}
}
local fields = {'song_title', 'album', 'type', 'singers'}
local fields = { 'song_title', 'album', 'type', 'singers' }
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 rows = {}
local rowspans = {}
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
local singers = mw.text.split(row.singers, ", ")
local singers = mw.text.split(row.singers, ",")
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 not row.type or row.type == "solover" or row.type == "solo" then
local type
if row.type == "solover" then
if row.type == "solover" then
                    type = "'''" .. horseName .. " ver.'''"
type = "'''" .. horseName .. " ver.'''"
                elseif #singers == 1 then
elseif #singers == 1 then
                    type = "'''Solo'''"
type = "'''Solo'''"
                else
elseif not row.type then
                    type = "Group"
type = "Group"
                end          
end
                local count = songnumber[row.song_title]
 
if count > 1 then
if type then
                    if not checked[row.song_title] then
table.insert(rows, { song = row.song_title, album = row.album, type = row.type })
                        table = table .. '|-\n| rowspan="' .. count .. '" | [[' .. row.song_title .. ']] || [[' .. row.album .. ']] || ' .. type .. '\n'
rowspans[row.song_title] = (rowspans[row.song_title] or 0) + 1
                        checked[row.song_title] = true 
end
                    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


    table = table .. '|}'
local text = '{| class="wikitable sortable mw-collapsible"\n! Song !! Album !! Type\n'
   
for row in rows do
    return table
text = text ..
string.format('|-\n| rowspan=%d|[[%s]] || [[%s]] || %s\n', rowspans[row.song], row.song, row.album, row.type)
end
text = text .. '|}'
 
return text
end
end
return p
return p

Navigation menu