3,726
edits
MusikAnimal (talk | contribs) No edit summary |
MusikAnimal (talk | contribs) No edit summary |
||
(14 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 | ||
if options['songs'] then | if options['songs'] then | ||
local songs = mw.text.split(options['songs'], ';', true) | local songs = mw.text.split(options['songs'], ';', true) | ||
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[' | 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'] ~= ' | if options['acoustic'] and options['acoustic'] ~= 'All' then | ||
table.insert(wheres, "live_songs.acoustic = | 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[' | if options['prerecorded'] and options['prerecorded'] ~= 'All' then | ||
table.insert(wheres, "live_songs. | table.insert(wheres, "live_songs.prerecorded = " .. normalize_song_option(options['prerecorded'])) | ||
end | end | ||
if options[' | if options['vip'] and options['vip'] ~= 'All' then | ||
table.insert(wheres, "live_songs. | table.insert(wheres, "live_songs.vip = " .. normalize_song_option(options['vip'])) | ||
end | end | ||
if options[' | if options['tease'] and options['tease'] ~= 'All' then | ||
table.insert(wheres, "live_songs. | table.insert(wheres, "live_songs.tease = " .. normalize_song_option(options['tease'])) | ||
end | end | ||
if options[' | if options['abandoned'] and options['abandoned'] ~= 'All' then | ||
table.insert(wheres, "live_songs. | 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 \"" .. | 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 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( | 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 | ||
totals_info = {} | totals_info = {} | ||
local num_artists = #get_keys(artists) | |||
if num_artists > 1 then | |||
table.insert(totals_info, num_artists .. ' artists') | |||
end | |||
if acoustic > 0 then | if acoustic > 0 then | ||
table.insert(totals_info, acoustic .. ' acoustic') | table.insert(totals_info, acoustic .. ' acoustic') | ||
Line 436: | 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 | ||