Module:Issue: Difference between revisions

From atwg
No edit summary
No edit summary
Line 75: Line 75:
result = #issues.results .. ' issues.\n\n'
result = #issues.results .. ' issues.\n\n'
result = result .. '{| class="wikitext issue_table" style="border:1px solid #ccc;border-collapse:collapse;"\n'
result = result .. '{| class="wikitext issue_table" style="border:1px solid #ccc;border-collapse:collapse;"\n'
result = result .. '! style="border:1px solid white;background-color:cornflowerblue;color:white;" | \n'
result = result .. '! style="border:1px solid white;background-color:steelblue;color:white;" | \n'


for k,v in ipairs( p.Taxonomy ) do
for k,v in ipairs( p.Taxonomy ) do
result = result .. '! colspan=' .. #v.values .. ' style="border:1px solid white;background-color:cornflowerblue;color:white;"| ' .. v.name .. '\n'
result = result .. '! colspan=' .. #v.values .. ' style="border:1px solid white;background-color:steelblue;color:white;"| ' .. v.name .. '\n'
end
end


result = result .. '|-\n'
result = result .. '|-\n'
result = result .. '! style="border:1px solid white;background-color:cornflowerblue;color:white;" | Issue\n'
result = result .. '! style="border:1px solid white;background-color:steelblue;color:white;" | Issue\n'
for k1,v1 in ipairs( p.Taxonomy ) do
for k1,v1 in ipairs( p.Taxonomy ) do
for k2,v2 in ipairs( v1.values ) do
for k2,v2 in ipairs( v1.values ) do
result = result .. '! style="border:1px solid white;background-color:cornflowerblue;color:white;" | ' ..
result = result .. '! style="border:1px solid white;background-color:steelblue;color:white;" | ' ..
frame:expandTemplate{ title = 'Tag Link', args = { v2 } } .. '\n'
frame:expandTemplate{ title = 'Tag Link', args = { v2 } } .. '\n'
end
end

Revision as of 09:00, 17 January 2018

Documentation for this module may be created at Module:Issue/doc

local p = {}

p.Taxonomy = {
	{
		name = "High Level",
		property = "High Level Property",
		values = {
			"Product Strategy",
			"Platform Strategy",
			"Culture",
			"Process",
			"Department Alignment"
		}
	},
	{
		name = "Technology",
		property = "Technology Property",
		values = {
			"APIs",
			"SOA",
			"MediaWiki",
			"Caching / Storage",
			"Performance / Scaling",
			"Build / Dev / Deploy",
			"Analytics / A/B testing",
			"(Isomorphic) JS"
		}
	},
	{
		name = "Customers",
		property = "Customer Property",
		values = {
			"3rd Party Installs",
			"3rd Party Clients",
			"Operational Burden",
			"Maintenance Burden",
			"Development Burden"
		}
	},
	{
		name = "Time",
		property = "Time Property",
		values = {
			"3-12 months",
			"2-5 years"
		}
	},
	{
		name = "Symptom or Cause",
		property = "Symptom or Cause",
		values = {
			"Is Symptom",
			"Is Cause"
		}
	}
}

function p.displayMatrix(frame)

	local query = '[[Category:Issues]]'
	if frame.args['tag'] ~= nil then
		query = query .. '[[Tag::' .. frame.args['tag'] .. ']]'
	end
	query = query .. "|?Description"
	for k,v in ipairs( p.Taxonomy ) do
		query = query .. '|?' .. v.property
	end
	query = query .. "|limit=1000";
    local issues = mw.smw.getQueryResult( query )

    if issues == nil or #issues.results == 0 then
        return "no issues found"
    end

	result = #issues.results .. ' issues.\n\n'
	result = result .. '{| class="wikitext issue_table" style="border:1px solid #ccc;border-collapse:collapse;"\n'
	result = result .. '! style="border:1px solid white;background-color:steelblue;color:white;" | \n'

	for k,v in ipairs( p.Taxonomy ) do
		result = result .. '! colspan=' .. #v.values .. ' style="border:1px solid white;background-color:steelblue;color:white;"| ' .. v.name .. '\n'
	end

	result = result .. '|-\n'
	result = result .. '! style="border:1px solid white;background-color:steelblue;color:white;" | Issue\n'
	
	for k1,v1 in ipairs( p.Taxonomy ) do
		for k2,v2 in ipairs( v1.values ) do
			result = result .. '! style="border:1px solid white;background-color:steelblue;color:white;" | ' ..
			frame:expandTemplate{ title = 'Tag Link', args = { v2 } } .. '\n'
		end
	end

	for k1,v1 in pairs( issues.results ) do
		result = result .. '|-\n'
		result = result .. '| style="border:1px solid #ccc;" | [[' .. v1.fulltext .. '|' .. v1.printouts['Description'][1] .. ']]\n'
		for k2,v2 in ipairs( p.Taxonomy ) do
			local query_values = v1.printouts[v2.property]
			for k3,v3 in ipairs( v2.values ) do
				result = result .. '| style="border:1px solid #ccc;text-align:center;min-width:60px;" |'
				for k4,v4 in pairs(query_values) do
					if v3 == v4 then
						result = result .. 'X'
					end
				end
				result = result .. '\n'
			end
		end
	end

	result = result .. '|}'
    return result
end

return p