Module:Album gallery

local p = {} local cargo = mw.ext.cargo

function p.buildArtists(artists) local ret = 'albums.artist IN ('	local new_artists = ''	for r = 1, #artists do		new_artists = new_artists .. '"' .. artists[r] .. '"'		if r ~= #artists then			new_artists = new_artists .. " AND "		end	end	mw.logObject(ret .. new_artists .. ')')	return ret .. new_artists .. ')' end

function p.buildTypes(types, holdsLike) local ret = '('	for t in #types do		if t ~= #types then			ret = ret .. ' AND '		end		ret = ret .. 'albums.type HOLDS "' .. types[t] .. '"'	end	if holdsLike then		ret = ret .. ' AND albums.type HOLDS LIKE "' .. holdsLike .. '"'	end

return ret .. ')' end

function p._list(artists) local types = {"bootleg", "compilation", "demo", "ep", "live", "promotional", "tribute", "video", "soundtrack"} local results = cargo.query( 'albums,releases', 'cover,albums._pageName=pageName,name', {		where = p.buildArtists(artists) .. ' AND ' .. builtTypes(types, {'%tutio'}) .. ' AND ' .. 'releases.release_date != ""',		join = 'albums._pageName=releases._pageName',		orderBy = 'release_date ASC',		groupBy = 'albums.name'	} )

return results end

return p