Module:Tour stats: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 30: Line 30:
where = 'name = "' .. song .. '"' .. fullSongSql .. artistSql,
where = 'name = "' .. song .. '"' .. fullSongSql .. artistSql,
join = 'live_songs._pageName = shows._pageName',
join = 'live_songs._pageName = shows._pageName',
groupBy = 'page_name',
groupBy = 'page_name, live_songs._ID',
orderBy = 'date ' .. order,
orderBy = 'date ' .. order,
limit = 1
limit = 1
Line 173: Line 173:
end
end
if prerecorded > 0 then
if prerecorded > 0 then
-- FIX ME: make these accept artist
-- FIXME: make these accept artist
local prerecordedStr = "[https://spcodex.wiki/Special:CargoQuery?title=Special%3ACargoQuery&tables=live_songs%2C+shows%2C+live_show_photos%2C+live_show_videos&fields=live_songs._pageName%3Dpage_name%2C+shows.date%3Ddate%2C+shows.artist%3Dartist%2C+shows.featuring_artist%3Dfeaturing_artist%2C+shows.venue%3Dvenue%2C+shows.location%3Dlocation%2C+shows.festival%3Dfestival%2C+shows.notes%3Dnotes%2C+live_songs.tease%3Dtease%2C+live_songs.abandoned%3Dabandoned%2C+live_songs.soundcheck%3Dsoundcheck%2C+live_songs.acoustic%2C+live_songs.piano%2C+IF%28live_show_photos._pageName+IS+NULL+AND+shows.poster+IS+NULL%2C+%27%27%2C+%271%27%29%3Dphotos%2C+live_show_videos._ID%3Dvideo&where=live_songs.prerecorded+%3D+1+AND+live_songs.name+%3D+%22" ..
local prerecordedStr = "[https://spcodex.wiki/Special:CargoQuery?title=Special%3ACargoQuery&tables=live_songs%2C+shows%2C+live_show_photos%2C+live_show_videos&fields=live_songs._pageName%3Dpage_name%2C+shows.date%3Ddate%2C+shows.artist%3Dartist%2C+shows.featuring_artist%3Dfeaturing_artist%2C+shows.venue%3Dvenue%2C+shows.location%3Dlocation%2C+shows.festival%3Dfestival%2C+shows.notes%3Dnotes%2C+live_songs.tease%3Dtease%2C+live_songs.abandoned%3Dabandoned%2C+live_songs.soundcheck%3Dsoundcheck%2C+live_songs.acoustic%2C+live_songs.piano%2C+IF%28live_show_photos._pageName+IS+NULL+AND+shows.poster+IS+NULL%2C+%27%27%2C+%271%27%29%3Dphotos%2C+live_show_videos._ID%3Dvideo&where=live_songs.prerecorded+%3D+1+AND+live_songs.name+%3D+%22" ..
mw.uri.encode(song) .. '%22&join_on=shows._pageName+%3D+live_songs._pageName%2C+shows._pageName%3Dlive_show_photos._pageName%2C+shows._pageName%3Dlive_show_videos._pageName&group_by=shows._pageName&having=&order_by%5B0%5D=shows.date+ASC&order_by_options%5B0%5D=ASC&limit=1000&format=template&template=Live+show+row&named+args=yes ' .. prerecorded .. " prerecorded]"
mw.uri.encode(song) .. '%22&join_on=shows._pageName+%3D+live_songs._pageName%2C+shows._pageName%3Dlive_show_photos._pageName%2C+shows._pageName%3Dlive_show_videos._pageName&group_by=shows._pageName&having=&order_by%5B0%5D=shows.date+ASC&order_by_options%5B0%5D=ASC&limit=1000&format=template&template=Live+show+row&named+args=yes ' .. prerecorded .. " prerecorded]"
Line 233: Line 233:


function p._query(options)
function p._query(options)
local tables = { 'shows', 'live_songs' }
local tables = { 'shows', 'live_songs', 'live_show_photos', 'live_show_videos' }
local fields = {
local fields = {
'shows._pageName=page_name',
'shows._pageName=page_name',
Line 239: Line 239:
'shows.featuring_artist=featuring_artist',
'shows.featuring_artist=featuring_artist',
'shows.tour=tour',
'shows.tour=tour',
'shows.date=date',
"(CASE WHEN shows.date__precision = 1 THEN shows.date WHEN shows.date__precision = 2 THEN DATE_FORMAT(shows.date, '%Y-%m-XX') ELSE DATE_FORMAT(shows.date, '%Y-XX-XX') END)=date",
'shows.venue=venue',
'shows.venue=venue',
'shows.venue_wikitext=venue_wikitext',
'shows.location=location',
'shows.location=location',
'shows.festival=festival'
'shows.festival=festival',
"live_songs.acoustic=acoustic",
"live_songs.piano=piano",
"live_songs.tease=tease",
"live_songs.abandoned=abandoned",
"live_songs.length=length",
"live_songs.vip=vip",
"live_songs.soundcheck=soundcheck",
"IF(live_show_photos._pageName IS NULL AND shows.poster IS NULL, NULL, '1')=photos",
"IF(live_show_videos._pageName IS NULL, NULL, '1')=video",
}
}
local wheres = {}
local wheres = {}
local joins = {
local joins = {
['live_songs._pageName'] = 'shows._pageName'
['live_songs._pageName'] = 'shows._pageName',
['shows._pageName'] = 'live_show_photos._pageName',
['live_show_photos._pageName'] = 'live_show_videos._pageName'
}
}