Module:Sandbox/KickahaOta/QueryDistances

From Path of Exile Wiki
Revision as of 02:17, 16 December 2021 by KickahaOta (talk | contribs) (In progress)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Module documentation[create] [purge]
local getArgs = require('Module:Arguments').getArgs
local m_util = require('Module:Util')
local m_cargo = require('Module:Cargo')

local m_tablecalc = {}

m_tablecalc.simpleval = 23

function m_tablecalc.testquery()
	local results = m_cargo.query(
		{'passive_skills'},
		{'passive_skills.name', 'passive_skills.id', 'passive_skills.connections', 'passive_skills.ascendancy_class', 'CONCAT("")=distance'},
		{where='passive_skills.ascendancy_class="Berserker"', order_by='passive_skills.id'}
	)
	return results
end

function m_tablecalc.computedistance()
	-- Takes 2 arguments:
	--   queryresults - table returned from m_cargo.query
	--   args
	--     idfield - string; the name of the field containing a row's id for connection purposes (for example, "passive_skills.id")
	--     connectionidsfield - string: the name of the field containing the ids of the rows that a given row connects to
	--        (for example, "passive_skills.connections")
	--     connectionidsdelimiter - string; the delimeter separating ids in the connectiond id field (for example, ",")
	--     originrowid - string; the id of a row that should be used as the starting point of the calculation. (For example,
	--       "AscendancyBerserkerStart" to start at the starting node in the Berserker's Ascendancy tree.)
	--     distancefield - string; the name of the field that should hold each row's calculated distance from the starting
	--       point. (This will be an integer. The row identified by originrowid will have a distance value of 0; the rows
	--       connected to that row will have a distance value of 1; the rows connected to those rows will have a distance value
	--       of 2; and so on.)
	-- Returns: A table that is a copy of the table in queryresults, except that each row will have the field identified by
	--   distancefield set to the calculated distance. The field will be created if it does not already exist in each row.

	local foundOriginRow = false
end

return m_tablecalc