Module:Tour stats: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}
local cargo = mw.ext.cargo
local cargo = mw.ext.cargo
local multi_song = false


local function get_keys(t)
local function get_keys(t)
Line 102: Line 103:


if full ~= '' and full ~= nil then
if full ~= '' and full ~= nil then
after_sql = ' AND tease = 0 AND abandoned = 0 AND prerecorded = 0'
after_sql = ' AND tease = 0 AND abandoned = 0 AND soundcheck = 0 AND prerecorded = 0'
end
end


Line 230: Line 231:
local artist = frame.args[3]
local artist = frame.args[3]
return p._main(song, longest, artist)
return p._main(song, longest, artist)
end
local function normalize_song_option(value)
if value:sub(1, 7) == 'Include' then
return 1
end
return 0
end
end


Line 245: Line 253:
'shows.location=location',
'shows.location=location',
'shows.festival=festival',
'shows.festival=festival',
'shows.notes=notes',
"IF(live_show_photos._pageName IS NULL AND shows.poster IS NULL, NULL, '1')=photos",
"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",
"IF(live_show_videos._pageName IS NULL, NULL, '1')=video",
Line 257: Line 266:


-- live_songs options
-- live_songs options
local multiSong = false
if options['songs'] then
if options['songs'] then
local songs = mw.text.split(options['songs'], ';', true)
local songs = mw.text.split(options['songs'], ';', true)
multiSong = #songs > 1
multi_song = #songs > 1
local songWheres = {}
local songWheres = {}
for r = 1, #songs do
for r = 1, #songs do
Line 267: Line 275:
table.insert(wheres, "(" .. table.concat(songWheres, ' OR ') .. ")")
table.insert(wheres, "(" .. table.concat(songWheres, ' OR ') .. ")")
end
end
if options['show_songs'] or multiSong or options['grouping'] == 'Group by song' then
if multi_song or (options['songs'] and options['grouping'] == 'Group by song') then
table.insert(groups, "live_songs._ID")
table.insert(groups, "live_songs._ID")
end
if options['songs'] then
table.insert(fields, "live_songs.name=song")
table.insert(fields, "live_songs.name=song")
table.insert(fields, "live_songs.acoustic=acoustic")
table.insert(fields, "live_songs.acoustic=acoustic")
Line 278: Line 288:
table.insert(fields, "live_songs.soundcheck=soundcheck")
table.insert(fields, "live_songs.soundcheck=soundcheck")
end
end
if options['acoustic'] and options['acoustic'] ~= 'No' then
if options['acoustic'] and options['acoustic'] ~= 'All' then
table.insert(wheres, "live_songs.acoustic = 1")
table.insert(wheres, "live_songs.acoustic = " .. normalize_song_option(options['acoustic']))
end
if options['piano'] and options['piano'] ~= 'All' then
table.insert(wheres, "live_songs.piano = " .. normalize_song_option(options['piano']))
end
if options['soundcheck'] and options['soundcheck'] ~= 'All' then
table.insert(wheres, "live_songs.soundcheck = " .. normalize_song_option(options['soundcheck']))
end
end
if options['piano'] and options['piano'] ~= 'No' then
if options['prerecorded'] and options['prerecorded'] ~= 'All' then
table.insert(wheres, "live_songs.piano = 1")
table.insert(wheres, "live_songs.prerecorded = " .. normalize_song_option(options['prerecorded']))
end
end
if options['soundcheck'] and options['soundcheck'] ~= 'No' then
if options['vip'] and options['vip'] ~= 'All' then
table.insert(wheres, "live_songs.soundcheck = 1")
table.insert(wheres, "live_songs.vip = " .. normalize_song_option(options['vip']))
end
end
if options['prerecorded'] and options['prerecorded'] ~= 'No' then
if options['tease'] and options['tease'] ~= 'All' then
table.insert(wheres, "live_songs.prerecorded = 1")
table.insert(wheres, "live_songs.tease = " .. normalize_song_option(options['tease']))
end
end
if options['vip'] and options['vip'] ~= 'No' then
if options['abandoned'] and options['abandoned'] ~= 'All' then
table.insert(wheres, "live_songs.vip = 1")
table.insert(wheres, "live_songs.abandoned = " .. normalize_song_option(options['abandoned']))
end
end
if options['cover_artist'] and options['cover_artist'] ~= 'No' then
if options['cover_artist'] and options['cover_artist'] ~= 'No' then
table.insert(wheres, "live_songs.cover = \"" .. options['cover_artist'] .. "\"")
table.insert(wheres, "live_songs.cover = \"" .. options['cover_artist'] .. "\"")
end
if options['length'] and options['length'] ~= 'No' then
local secs = require('Module:Live song')._time_to_seconds(options['length'])
table.insert(wheres, "live_songs.seconds >= " .. secs)
end
end


Line 313: Line 333:
local bandsWheres = {}
local bandsWheres = {}
for r = 1, #bands do
for r = 1, #bands do
table.insert(bandsWheres, "shows.bands HOLDS \"" .. personnel[r] .. "\"")
table.insert(bandsWheres, "shows.bands HOLDS \"" .. bands[r] .. "\"")
end
end
table.insert(wheres, "(" .. table.concat(bandsWheres, ' OR ') .. ")")
table.insert(wheres, "(" .. table.concat(bandsWheres, ' OR ') .. ")")
Line 351: Line 371:
offset = offset,
offset = offset,
groupBy = table.concat(groups, ','),
groupBy = table.concat(groups, ','),
orderBy = 'shows.date ASC',
limit = 5000
limit = 5000
}
}
Line 361: Line 382:
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame)
local args = getArgs(frame)
local filters = {
songs = false,
acoustic = false,
piano = false,
soundcheck = false,
tease = false,
abandoned = false,
prerecorded = false,
vip = false,
cover_artist = false,
artist = false,
personnel = false,
bands = false,
country = false,
coords = false,
venue = false,
venue_type = false,
tour = false,
date_after = false,
date_before = false,
offset = false,
show_songs = false,
}


local results = p._query(args)
local results = p._query(args)
Line 403: Line 401:
local acoustic = 0
local acoustic = 0
local piano = 0
local piano = 0
local soundcheck = 0
for r = 1, #results do
for r = 1, #results do
local result = results[r]
local result = results[r]
list:node(get_row(result))
if multi_song then
result['multi_song'] = '1'
end
local success, row_node = pcall(get_row, result)
if success == false then
error('Too many results! Try narrowing your search criteria')
else
list:node(row_node)
end


-- For counts
-- For counts
Line 421: Line 428:
if result['piano'] == '1' then
if result['piano'] == '1' then
piano = piano + 1
piano = piano + 1
end
if result['soundcheck'] == '1' then
soundcheck = soundcheck + 1
end
end
end
end
Line 440: Line 450:
if abandoned > 0 then
if abandoned > 0 then
table.insert(totals_info, abandoned .. ' abandoned')
table.insert(totals_info, abandoned .. ' abandoned')
end
if soundcheck > 0 then
table.insert(totals_info, soundcheck .. ' soundcheck')
end
end