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, args.tab)
end
function p.main(args, tab)
util_vars.setVar('sbTabName', tab)
util_vars.setGlobalIndex('sb_N_TabInPage')
if not util_args.castAsBool(args.continue) then
return
end
local result = util_cargo.getOneRow(h.makeQuery(tab)) or {}
util_vars.resetGlobalIndex('sb_N_MatchInTab', result.N_MatchInTab)
end
function h.makeQuery(tab)
local query = {
tables = { 'ScoreboardCounters=SC' },
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
'COUNT(*)=N_MatchInTab [number]',
},
}
return query
end
function h.getWhere(tab)
local where = {
('SC.OverviewPage="%s"'):format(util_esports.getOverviewPage()),
('SC.Tab="%s"'):format(tab),
('SC.N_ScoreboardPage<"%s"'):format(util_vars.getVar('tabThis'))
}
return where
end
return p