Открыть меню
Открыть персональное меню
Вы не представились системе
Your IP address will be publicly visible if you make any edits.

Модуль:ICCup entity count

Материал из wiki.iccup.org
Версия от 21:37, 31 августа 2024; DarkMuse (обсуждение | вклад) (Новая страница: «local Arguments = require('Module:Arguments') local EntityCounter = {} function EntityCounter.count(frame) return EntityCounter._count(Arguments.getArgs(frame)) end function EntityCounter._count(args) local smwQuery = args.query local conditions = args.conditions local queryString = "" .. smwQuery .. "" if conditions then queryString = queryString .. conditions end local res = mw.smw.ask { queryString, "format=count" } if type(res) =...»)
(разн.) ← Предыдущая версия | Текущая версия (разн.) | Следующая версия → (разн.)

Для документации этого модуля может быть создана страница Модуль:ICCup entity count/doc

local Arguments = require('Module:Arguments')

local EntityCounter = {}

function EntityCounter.count(frame)
	return EntityCounter._count(Arguments.getArgs(frame))
end

function EntityCounter._count(args)
	local smwQuery = args.query
	local conditions = args.conditions
	local queryString = "[[" .. smwQuery .. "]]"

	if conditions then
		queryString = queryString .. conditions
	end

	local res = mw.smw.ask {
		queryString,
		"format=count"
	}

	if type(res) == 'table' and res[1] then
		return res[1]
	else
		error("Ошибка при выполнении запроса: " .. tostring(res))
	end
end

return EntityCounter