From Leaguepedia | League of Legends Esports Wiki
Jump to: navigation, search

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

local util_args = require('Module:ArgsUtil')
local util_cargo = require("Module:CargoUtil")
local util_esports = require("Module:EsportsUtil")
local util_html = require("Module:HtmlUtil")
local util_map = require('Module:MapUtil')
local util_table = require("Module:TableUtil")
local util_text = require("Module:TextUtil")
local util_vars = require("Module:VarsUtil")
local i18n = require("Module:I18nUtil")
local lang = mw.getLanguage('en')

-- this module resets counters of start-of-page stuff at a value other than 0
-- this makes the page query all previous pages with the same tab name
-- and accordingly offset the indices to match those in MSG
-- see Template:Scoreboard/Tab for usage documentation

local h = {}

local p = {}

function p.test(frame)
	local args = util_args.merge()
	return p.main(args,

function p.main(args, tab)
	util_vars.setVar('sbTabName', tab)
	if not util_args.castAsBool(args.continue) then
	local result = util_cargo.getOneRow(h.makeQuery(tab)) or {}
	util_vars.resetGlobalIndex('sb_N_MatchInTab', result.N_MatchInTab)

function h.makeQuery(tab)
	local query = {
		tables = { 'ScoreboardGames=SG', 'MatchScheduleGame=MSG', 'MatchSchedule=MS' },
		join = {
		where = h.getWhere(tab),
		fields = {
			-- This was previously COUNT DISTINCT and i see no reason for that
			-- a number can be skipped if there is a forfeit etc
			'MAX(MSG.N_MatchInTab)=N_MatchInTab [number]',
	return query

function h.getWhere(tab)
	local where = {
	return where

return p