Module:Water Ritual Liquids

local util_args = require('Module:Args Utility') local util_cargo = require('Module:Cargo Utility') local util_map = require('Module:Map Utility') local util_html = require('Module:HTML Utility') local util_table = require('Module:Table Utility') local util_text = require('Module:Text Utility') local favilink = require('Module:Favilink')

local COLUMNS = { 'Liquid', 'Factions' }

local h = {}

local p = {}

function p.main(frame)

frame=mw.getCurrentFrame local data = h.makeAndRunQuery(nil) h.formatRows(data) return h.makeOutput(data) end

function h.makeAndRunQuery(args) return util_cargo.queryAndCast(h.makeQuery(args)) end

function h.makeQuery(args) local query = { tables = { 'Factions=F' }, fields = h.getFields, where = '(F._pageNamespace="14" OR F._pageNamespace="0") AND IsVisible="1"', orderBy = 'WaterRitualLiquid ASC', oneToMany = { fields = { 'CONCAT("", PlainName, "")=Factions', 'WaterRitualLiquid' }, groupBy = { 'WaterRitualLiquid' }, },	}	return query end

function h.getFields return { 'WaterRitualLiquid=Liquid' } end

function h.formatRows(data) util_map.rowsInPlace(data, h.formatOneRow) end

function h.formatOneRow(row) row.Factions = util_table.concat(row.Factions, ' • ') row.Liquid = favilink.modulefavilink(row.Liquid) end

function h.makeOutput(data) local output = mw.html.create local tbl = output:tag('table') :addClass('wikitable') :addClass('sortable') util_html.printHeader(tbl, COLUMNS) util_html.printRowsByList(tbl, data, COLUMNS) return output end

return p