Module:Musician tour stats: Difference between revisions

no edit summary
No edit summary
No edit summary
 
Line 12: Line 12:
'shows.date=date, shows.venue=venue, shows.location=location, ',
'shows.date=date, shows.venue=venue, shows.location=location, ',
{
{
where = 'lineup HOLDS "' .. artist .. '"',
where = 'lineup HOLDS "' .. artist .. '" AND date <= NOW()',
orderBy = 'date ' .. order,
orderBy = 'date ' .. order,
limit = 1
limit = 1
Line 48: Line 48:
'shows',
'shows',
"COUNT(_ID)=total",
"COUNT(_ID)=total",
{ where = 'lineup HOLDS "' .. artist .. '"' }
{ where = 'lineup HOLDS "' .. artist .. '" AND date <= NOW()' }
)[1]
)[1]
if counts['total'] == '0' then
return ''
end


local statsRoot = root:tag('ul')
local statsRoot = root:tag('ul')


-- Totals
-- Totals
local totalShows = tonumber(counts['total'])
local totalShows = mw.language.getContentLanguage():formatNum(tonumber(counts['total']))
local totalsRow = statsRoot:tag('li')
local totalsRow = statsRoot:tag('li')
totalsRow:tag('b'):wikitext('Total shows: ')
totalsRow:tag('b'):wikitext('Total shows: ')
Line 69: Line 65:
-- First show
-- First show
local firstShow = fetchShow(artist, true)[1]
local firstShow = fetchShow(artist, true)[1]
createRowForShow(statsRoot, firstShow, 'First performance')
if firstShow then
createRowForShow(statsRoot, firstShow, 'First performance')
end


-- Last show
-- Last show
local lastShow = fetchShow(artist, false)[1]
local lastShow = fetchShow(artist, false)[1]
createRowForShow(statsRoot, lastShow, 'Last performance')
if lastShow then
createRowForShow(statsRoot, lastShow, 'Last performance')
end


return '== Touring stats ==\n' .. tostring(root)
return '== Touring stats ==\n' .. tostring(root)