<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://staging.twogpedia.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AAllBroadcasts</id>
	<title>Module:AllBroadcasts - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://staging.twogpedia.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AAllBroadcasts"/>
	<link rel="alternate" type="text/html" href="https://staging.twogpedia.com/index.php?title=Module:AllBroadcasts&amp;action=history"/>
	<updated>2026-05-13T10:50:58Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://staging.twogpedia.com/index.php?title=Module:AllBroadcasts&amp;diff=8084&amp;oldid=prev</id>
		<title>Couchor: Created page with &quot;local cargo = mw.ext.cargo local Func = require(&#039;Module:Functions&#039;) local getTeamLogo = Func.getTeamLogo local stringifyDate = Func.stringifyDate local prizeToString = Func.prizeToString local getTeamDisplaytitle = Func.getTeamDisplaytitle local makeFlag = require(&#039;Module:Person/Flag&#039;).makeFlag  local p = {}  function p.main(frame) 	-- TOURNAMENTS AS TALENT 	local currentTitle = mw.title.getCurrentTitle().text 	local split = mw.text.split(currentTitle, &#039;/&#039;) 	local person...&quot;</title>
		<link rel="alternate" type="text/html" href="https://staging.twogpedia.com/index.php?title=Module:AllBroadcasts&amp;diff=8084&amp;oldid=prev"/>
		<updated>2023-11-12T20:10:45Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local cargo = mw.ext.cargo local Func = require(&amp;#039;Module:Functions&amp;#039;) local getTeamLogo = Func.getTeamLogo local stringifyDate = Func.stringifyDate local prizeToString = Func.prizeToString local getTeamDisplaytitle = Func.getTeamDisplaytitle local makeFlag = require(&amp;#039;Module:Person/Flag&amp;#039;).makeFlag  local p = {}  function p.main(frame) 	-- TOURNAMENTS AS TALENT 	local currentTitle = mw.title.getCurrentTitle().text 	local split = mw.text.split(currentTitle, &amp;#039;/&amp;#039;) 	local person...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local cargo = mw.ext.cargo&lt;br /&gt;
local Func = require(&amp;#039;Module:Functions&amp;#039;)&lt;br /&gt;
local getTeamLogo = Func.getTeamLogo&lt;br /&gt;
local stringifyDate = Func.stringifyDate&lt;br /&gt;
local prizeToString = Func.prizeToString&lt;br /&gt;
local getTeamDisplaytitle = Func.getTeamDisplaytitle&lt;br /&gt;
local makeFlag = require(&amp;#039;Module:Person/Flag&amp;#039;).makeFlag&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	-- TOURNAMENTS AS TALENT&lt;br /&gt;
	local currentTitle = mw.title.getCurrentTitle().text&lt;br /&gt;
	local split = mw.text.split(currentTitle, &amp;#039;/&amp;#039;)&lt;br /&gt;
	local person = split[1] .. &amp;#039;/&amp;#039; .. split[2]&lt;br /&gt;
	&lt;br /&gt;
	local parentDT = mw.ext.displaytitle.get(person)&lt;br /&gt;
	local newDT = parentDT .. &amp;#039; - Broadcasts&amp;#039;&lt;br /&gt;
	local seoArgs = {&lt;br /&gt;
		title_mode = &amp;#039;replace&amp;#039;,&lt;br /&gt;
		title = newDT .. &amp;#039; {{!}} TwogPedia&amp;#039;,&lt;br /&gt;
		description = &amp;#039;Detailed broadcast info of tournaments and matches for &amp;#039; .. parentDT,&lt;br /&gt;
		keywords = parentDT .. &amp;#039;,broadcasts,matches,tournaments&amp;#039;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	local tables = &amp;#039;Talent, Tournaments&amp;#039;&lt;br /&gt;
	local fields = &amp;#039;Talent.role=role, Talent.lang=lang, Tournaments.prize=prize, Tournaments._pageName=_pageName, Tournaments.type=type, Tournaments.start=start, Tournaments.end=end, Tournaments.country=country, Tournaments.participants=participants, Tournaments.formatFilter=formatFilter, Tournaments.logoAll=logoAll, Tournaments.logoLight=logoLight, Tournaments.logoDark=logoDark, Tournaments.iconAll=iconAll, Tournaments.iconLight=iconLight, Tournaments.iconDark=iconDark&amp;#039;&lt;br /&gt;
	local cargoArgs = {&lt;br /&gt;
		join = &amp;#039;Talent._pageName=Tournaments._pageName&amp;#039;,&lt;br /&gt;
		where = &amp;#039;Talent.people HOLDS &amp;quot;&amp;#039; .. person .. &amp;#039;&amp;quot;&amp;#039;,&lt;br /&gt;
		orderBy = &amp;#039;Tournaments.end desc&amp;#039;&lt;br /&gt;
	}&lt;br /&gt;
	local tournamentResults = cargo.query(tables, fields, cargoArgs)&lt;br /&gt;
	&lt;br /&gt;
	if #tournamentResults &amp;gt; 0 then&lt;br /&gt;
		return createTable(tournamentResults, person)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function createTable(results, person)&lt;br /&gt;
	local container = mw.html.create(&amp;#039;div&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
	if #results &amp;gt; 0 then&lt;br /&gt;
		local monthNames = {&amp;quot;Jan&amp;quot;, &amp;quot;Feb&amp;quot;, &amp;quot;Mar&amp;quot;, &amp;quot;Apr&amp;quot;, &amp;quot;May&amp;quot;, &amp;quot;Jun&amp;quot;, &amp;quot;Jul&amp;quot;, &amp;quot;Aug&amp;quot;, &amp;quot;Sep&amp;quot;, &amp;quot;Oct&amp;quot;, &amp;quot;Nov&amp;quot;, &amp;quot;Dec&amp;quot;}&lt;br /&gt;
		&lt;br /&gt;
		local roleTh = mw.html.create(&amp;#039;th&amp;#039;):wikitext(&amp;#039;Role&amp;#039;)&lt;br /&gt;
		local typeTh = mw.html.create(&amp;#039;th&amp;#039;):wikitext(&amp;#039;Type&amp;#039;)&lt;br /&gt;
		local nameTh = mw.html.create(&amp;#039;th&amp;#039;):wikitext(&amp;#039;Tournament&amp;#039;)&lt;br /&gt;
		local dateTh = mw.html.create(&amp;#039;th&amp;#039;):wikitext(&amp;#039;Date&amp;#039;)&lt;br /&gt;
		local prizeTh = mw.html.create(&amp;#039;th&amp;#039;):wikitext(&amp;#039;Prize&amp;#039;)&lt;br /&gt;
		local placementTh = mw.html.create(&amp;#039;th&amp;#039;):wikitext(&amp;#039;Winner&amp;#039;)&lt;br /&gt;
		local tableHeader = mw.html.create(&amp;#039;tr&amp;#039;):addClass(&amp;#039;tournament__header&amp;#039;):node(roleTh):node(nameTh):node(dateTh):node(prizeTh):node(placementTh)&lt;br /&gt;
&lt;br /&gt;
		local listTable = mw.html.create(&amp;#039;table&amp;#039;):addClass(&amp;#039;tournament__table&amp;#039;):attr(&amp;#039;style&amp;#039;, &amp;#039;width: -webkit-fill-available;&amp;#039;):node(tableHeader)&lt;br /&gt;
		container:node(listTable)&lt;br /&gt;
&lt;br /&gt;
		for i = 1, #results do&lt;br /&gt;
			local result = results[i]&lt;br /&gt;
			local icon = result.iconAll ~= &amp;#039;&amp;#039; and result.iconAll or result.iconLight ~= &amp;#039;&amp;#039; and result.iconLight or result.iconDark ~= &amp;#039;&amp;#039; and result.iconDark or result.logoAll ~= &amp;#039;&amp;#039; and result.logoAll or result.logoDark ~= &amp;#039;&amp;#039; and result.logoDark or result.logoLight ~= &amp;#039;&amp;#039; and result.logoLight&lt;br /&gt;
			if not icon then icon = &amp;#039;Tournament_placeholder.png&amp;#039; end&lt;br /&gt;
			&lt;br /&gt;
			local roleTd = mw.html.create(&amp;#039;td&amp;#039;):wikitext(result.lang .. &amp;#039; &amp;#039; .. string.sub(result.role, 1, -2))&lt;br /&gt;
			local typeTd = mw.html.create(&amp;#039;td&amp;#039;)&lt;br /&gt;
			local nameTd = mw.html.create(&amp;#039;td&amp;#039;):node(mw.html.create(&amp;#039;div&amp;#039;):addClass(&amp;#039;tournament__name&amp;#039;):wikitext(&amp;#039;[[File:&amp;#039; .. icon .. &amp;#039;|25px]]&amp;#039;):wikitext(&amp;#039;[[&amp;#039; .. result._pageName .. &amp;#039;]]&amp;#039;))&lt;br /&gt;
			local dateTd = mw.html.create(&amp;#039;td&amp;#039;)&lt;br /&gt;
			local prizeTd = mw.html.create(&amp;#039;td&amp;#039;):wikitext(&amp;#039;$&amp;#039; .. prizeToString(result.prize))&lt;br /&gt;
			local placementTd = mw.html.create(&amp;#039;td&amp;#039;):addClass(&amp;#039;tc&amp;#039;)&lt;br /&gt;
			&lt;br /&gt;
		&lt;br /&gt;
			-- Check if tournament has a winner&lt;br /&gt;
			tables = &amp;quot;Prizes&amp;quot;&lt;br /&gt;
		    fields = &amp;quot;teams&amp;quot;&lt;br /&gt;
		    cargoArgs = {&lt;br /&gt;
		    	where = &amp;#039;placement=&amp;quot;1&amp;quot; AND _pageName=&amp;quot;&amp;#039; .. result._pageName .. &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
		    }&lt;br /&gt;
		    local prizeResults = cargo.query(tables, fields, cargoArgs)&lt;br /&gt;
		    &lt;br /&gt;
		    if #prizeResults &amp;gt; 0 then&lt;br /&gt;
		    	placementTd:node(getTeamLogo(prizeResults[1].teams, mw.text.split(result._pageName, &amp;#039;/&amp;#039;)[1], &amp;#039;30x30px&amp;#039;))&lt;br /&gt;
			else&lt;br /&gt;
				placementTd:wikitext(&amp;#039;TBD&amp;#039;)	&lt;br /&gt;
		    end&lt;br /&gt;
&lt;br /&gt;
			local tournamentType = result.type and mw.text.split(result.type, &amp;#039;,&amp;#039;) or {}&lt;br /&gt;
			for j = 1, #tournamentType do&lt;br /&gt;
				typeTd:node(mw.html.create(&amp;#039;div&amp;#039;):wikitext(tournamentType[j]))&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			local startDate = &amp;#039;TBD&amp;#039;&lt;br /&gt;
			if result.start then&lt;br /&gt;
				local year, month, day = result.start:match(&amp;quot;(%d+)-(%d+)-(%d+)&amp;quot;)&lt;br /&gt;
				local monthName = monthNames[tonumber(month)]&lt;br /&gt;
				startDate = monthName .. &amp;quot; &amp;quot; .. day .. &amp;quot;, &amp;quot; .. year&lt;br /&gt;
			end&lt;br /&gt;
			local endDate = &amp;#039;TBD&amp;#039;&lt;br /&gt;
			if result[&amp;#039;end&amp;#039;] then&lt;br /&gt;
				year, month, day = result[&amp;#039;end&amp;#039;]:match(&amp;quot;(%d+)-(%d+)-(%d+)&amp;quot;)&lt;br /&gt;
				monthName = monthNames[tonumber(month)]&lt;br /&gt;
				endDate = monthName .. &amp;quot; &amp;quot; .. day .. &amp;quot;, &amp;quot; .. year&lt;br /&gt;
			end&lt;br /&gt;
			dateTd:node(mw.html.create(&amp;#039;div&amp;#039;):wikitext(startDate)):node(mw.html.create(&amp;#039;div&amp;#039;):wikitext(&amp;#039;-&amp;#039;)):node(mw.html.create(&amp;#039;div&amp;#039;):wikitext(endDate))&lt;br /&gt;
			&lt;br /&gt;
			local tournamentRow = mw.html.create(&amp;#039;tr&amp;#039;):node(roleTd):node(nameTd):node(dateTd):node(prizeTd):node(placementTd)&lt;br /&gt;
&lt;br /&gt;
			local currentTime = os.time()&lt;br /&gt;
			&lt;br /&gt;
			local startTime = nil&lt;br /&gt;
			if result.start then&lt;br /&gt;
				startTime = mw.ustring.gsub(result.start, &amp;#039;(%d+)-(%d+)-(%d+)&amp;#039;, function(year, month, day)&lt;br /&gt;
				    return os.time({year=tonumber(year), month=tonumber(month), day=tonumber(day)})&lt;br /&gt;
				end)	&lt;br /&gt;
			end&lt;br /&gt;
			local endTime = nil&lt;br /&gt;
			if result[&amp;#039;end&amp;#039;] then&lt;br /&gt;
				endTime = mw.ustring.gsub(result[&amp;#039;end&amp;#039;], &amp;#039;(%d+)-(%d+)-(%d+)&amp;#039;, function(year, month, day)&lt;br /&gt;
				    return os.time({year=tonumber(year), month=tonumber(month), day=tonumber(day)})&lt;br /&gt;
				end)&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			local date = mw.html.create(&amp;#039;div&amp;#039;)&lt;br /&gt;
			-- If live&lt;br /&gt;
			if (startTime ~= nil and os.difftime(currentTime, startTime) &amp;gt; 0) and (endTime == nil or os.difftime(currentTime, endTime) &amp;lt;= 0) then&lt;br /&gt;
				date:wikitext(&amp;#039;LIVE&amp;#039;)&lt;br /&gt;
			else &lt;br /&gt;
				local startDate = &amp;#039;TBD&amp;#039;&lt;br /&gt;
				if result.start then&lt;br /&gt;
					local year, month, day = result.start:match(&amp;quot;(%d+)-(%d+)-(%d+)&amp;quot;)&lt;br /&gt;
					local monthName = monthNames[tonumber(month)]&lt;br /&gt;
					startDate = monthName .. &amp;quot; &amp;quot; .. day .. &amp;quot;, &amp;quot; .. year&lt;br /&gt;
				end&lt;br /&gt;
				local endDate = &amp;#039;TBD&amp;#039;&lt;br /&gt;
				if result[&amp;#039;end&amp;#039;] then&lt;br /&gt;
					year, month, day = result[&amp;#039;end&amp;#039;]:match(&amp;quot;(%d+)-(%d+)-(%d+)&amp;quot;)&lt;br /&gt;
					monthName = monthNames[tonumber(month)]&lt;br /&gt;
					endDate = monthName .. &amp;quot; &amp;quot; .. day .. &amp;quot;, &amp;quot; .. year&lt;br /&gt;
				end&lt;br /&gt;
				date:wikitext(startDate .. &amp;#039; - &amp;#039; .. endDate)&lt;br /&gt;
			end&lt;br /&gt;
		    &lt;br /&gt;
			listTable:node(tournamentRow)&lt;br /&gt;
			-- Get matches of tournament&lt;br /&gt;
			local matches = getMatches(result._pageName, person)&lt;br /&gt;
			if matches then&lt;br /&gt;
				local matchesTd = mw.html.create(&amp;#039;td&amp;#039;):attr(&amp;#039;colspan&amp;#039;, 10):node(matches)&lt;br /&gt;
				local matchesRow = mw.html.create(&amp;#039;tr&amp;#039;):node(matchesTd)&lt;br /&gt;
				listTable:node(matchesRow)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		return container&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function getMatches(tournament, person)&lt;br /&gt;
	local game = mw.text.split(tournament, &amp;#039;/&amp;#039;)[1]&lt;br /&gt;
	local tables = &amp;#039;AllMatches&amp;#039;&lt;br /&gt;
	local fields = &amp;#039;_ID, _pageName, p1, p2, p1score, p2score, winner, date, bestof, stage&amp;#039;&lt;br /&gt;
	local cargoArgs = {&lt;br /&gt;
		where = &amp;#039;_pageName LIKE &amp;quot;&amp;#039; .. tournament .. &amp;#039;%&amp;quot; AND (casters HOLDS &amp;quot;&amp;#039; .. person .. &amp;#039;&amp;quot; OR observers HOLDS &amp;quot;&amp;#039; .. person .. &amp;#039;&amp;quot;) AND winner IS NOT NULL AND winner != &amp;quot;0&amp;quot;&amp;#039;,&lt;br /&gt;
		limit =  1000,&lt;br /&gt;
		orderBy = &amp;#039;date desc&amp;#039;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	local results = cargo.query(tables, fields, cargoArgs)&lt;br /&gt;
	&lt;br /&gt;
	if #results &amp;gt; 0 then&lt;br /&gt;
		local team = not string.find(results[1].p1, &amp;#039;People/&amp;#039;)&lt;br /&gt;
		local dateTh = mw.html.create(&amp;#039;th&amp;#039;):wikitext(&amp;#039;Date&amp;#039;)&lt;br /&gt;
		local vsTh = mw.html.create(&amp;#039;th&amp;#039;):wikitext(&amp;#039;Match&amp;#039;)&lt;br /&gt;
		local vodTh = mw.html.create(&amp;#039;th&amp;#039;):wikitext(&amp;#039;VODs&amp;#039;)&lt;br /&gt;
		local headerRow = mw.html.create(&amp;#039;tr&amp;#039;):addClass(&amp;#039;headerRow&amp;#039;):node(dateTh):node(vsTh):node(vodTh)&lt;br /&gt;
		local tbl = mw.html.create(&amp;#039;table&amp;#039;):addClass(&amp;#039;striped-table w-100&amp;#039;):node(headerRow)&lt;br /&gt;
		&lt;br /&gt;
		for i = 1, #results do&lt;br /&gt;
			local result = results[i]&lt;br /&gt;
&lt;br /&gt;
			local dateTd = mw.html.create(&amp;#039;td&amp;#039;):wikitext(stringifyDate(result.date) .. &amp;#039; &amp;#039;):node(mw.html.create(&amp;#039;abbr&amp;#039;):attr(&amp;#039;title&amp;#039;, &amp;#039;Coordinated Universal Time&amp;#039;):wikitext(&amp;#039;UTC&amp;#039;))&lt;br /&gt;
			local vsTd = mw.html.create(&amp;#039;td&amp;#039;)&lt;br /&gt;
			if team then &lt;br /&gt;
				vsTd:node(mw.html.create(&amp;#039;div&amp;#039;):attr(&amp;#039;style&amp;#039;, &amp;#039;display: flex; gap: 0.2rem; align-items: center; justify-content: center;&amp;#039;):node(getTeamLogo(result.p1, game, &amp;#039;20x20px&amp;#039;)):wikitext(&amp;#039;[[&amp;#039; .. result.p1 .. &amp;#039;|&amp;#039; .. getTeamDisplaytitle(result.p1, result.date) ..&amp;#039;]]&amp;#039;):wikitext(result.p1score .. &amp;#039;:&amp;#039; .. result.p2score):node(getTeamLogo(result.p2, game, &amp;#039;20x20px&amp;#039;)):wikitext(&amp;#039;[[&amp;#039; .. result.p2 .. &amp;#039;|&amp;#039; .. getTeamDisplaytitle(result.p2, result.date) ..&amp;#039;]]&amp;#039;))&lt;br /&gt;
			else&lt;br /&gt;
				vsTd:node(mw.html.create(&amp;#039;div&amp;#039;):attr(&amp;#039;style&amp;#039;, &amp;#039;display: flex; gap: 0.2rem; align-items: center; justify-content: center;&amp;#039;):wikitext(makeFlag(nil, result.p1)):wikitext(&amp;#039;[[&amp;#039; .. result.p1 .. &amp;#039;]]&amp;#039;):wikitext(result.p1score .. &amp;#039;:&amp;#039; .. result.p2score):wikitext(makeFlag(nil, result.p2)):wikitext(&amp;#039;[[&amp;#039; .. result.p2 .. &amp;#039;]]&amp;#039;))&lt;br /&gt;
			end&lt;br /&gt;
			local vodTd = mw.html.create(&amp;#039;td&amp;#039;)&lt;br /&gt;
			local resultRow = mw.html.create(&amp;#039;tr&amp;#039;):addClass(&amp;#039;bodyRow&amp;#039;):node(dateTd):node(vsTd):node(vodTd)&lt;br /&gt;
		&lt;br /&gt;
			&lt;br /&gt;
			-- Get VODs&lt;br /&gt;
			if game == &amp;#039;Dota2&amp;#039; then&lt;br /&gt;
				tables = &amp;#039;Maps_Dota&amp;#039;&lt;br /&gt;
				fields = &amp;#039;yt, vod&amp;#039;&lt;br /&gt;
				cargoArgs = {&lt;br /&gt;
					where = &amp;#039;matchID =&amp;quot;&amp;#039; .. result._ID .. &amp;#039;&amp;quot;&amp;#039;,&lt;br /&gt;
					orderBy = &amp;#039;map&amp;#039;&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
				local vods = cargo.query(tables, fields, cargoArgs)&lt;br /&gt;
				if #vods &amp;gt; 0 then&lt;br /&gt;
					for j = 1, #vods do&lt;br /&gt;
						local vod = vods[j]&lt;br /&gt;
						if vod.yt then&lt;br /&gt;
							vodTd:wikitext(&amp;#039;[[File:Youtube.png|20x20px|link=https://www.youtube.com/watch?v=&amp;#039; .. vod.yt .. &amp;#039;|Map &amp;#039; .. j .. &amp;#039;]]&amp;#039;)&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			tbl:node(resultRow)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		return tbl&lt;br /&gt;
	else&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Couchor</name></author>
	</entry>
</feed>