Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lua/wikis/commons/Widget/Tournament/Label.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ function TournamentsTickerLabelWidget:render()
css = {
['padding-left'] = self.props.displayGameIcon and '50px' or '25px',
},
children = {
Title{
tournament = tournament,
displayGameIcon = self.props.displayGameIcon
}
children = Title{
tournament = tournament,
displayGameIcon = self.props.displayGameIcon
},
},
HtmlWidgets.Small{
Expand Down
1 change: 0 additions & 1 deletion lua/wikis/commons/Widget/Tournament/TierPill.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ local HtmlWidgets = Lua.import('Module:Widget/Html/All')

---@class TournamentsTickerPillWidget: Widget
---@operator call(table): TournamentsTickerPillWidget

local TournamentsTickerPillWidget = Class.new(Widget)

local COLOR_CLASSES = {
Expand Down
6 changes: 3 additions & 3 deletions lua/wikis/commons/Widget/Tournament/Title.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ local Link = Lua.import('Module:Widget/Basic/Link')
---@field props TournamentTitleProps
local TournamentTitleWidget = Class.new(Widget)

---@return Widget?
---@return Widget[]?
function TournamentTitleWidget:render()
local tournament = self.props.tournament
if not tournament then
return
end

return HtmlWidgets.Fragment{children = WidgetUtil.collect(
return WidgetUtil.collect(
self.props.displayGameIcon and Game.icon{
game = tournament.game,
noLink = true,
Expand Down Expand Up @@ -62,7 +62,7 @@ function TournamentTitleWidget:render()
},
}
}
)}
)
end

return TournamentTitleWidget
25 changes: 17 additions & 8 deletions lua/wikis/commons/Widget/Tournaments/Ticker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ local Tournament = Lua.import('Module:Tournament')

---@class TournamentsTickerWidget: Widget
---@operator call(table): TournamentsTickerWidget

local TournamentsTickerWidget = Class.new(Widget)
TournamentsTickerWidget.defaultProps = {
upcomingDays = 5,
Expand All @@ -50,6 +49,9 @@ function TournamentsTickerWidget:render()
}

local currentTimestamp = DateExt.getCurrentTimestamp()

---@param tournament StandardTournament
---@return boolean
local function isWithinDateRange(tournament)
local modifiedThreshold = tierThresholdModifiers[tournament.liquipediaTier] or 0
local modifiedCompletedThreshold = tierTypeThresholdModifiers[tournament.liquipediaTierType] or modifiedThreshold
Expand All @@ -71,17 +73,17 @@ function TournamentsTickerWidget:render()
return false
end

local lpdbFilter = Condition.Tree(Condition.BooleanOperator.all)
:add(Condition.Tree(Condition.BooleanOperator.any)
:add(Condition.Node(Condition.ColumnName('status'), Condition.Comparator.eq, ''))
:add(Condition.Node(Condition.ColumnName('status'), Condition.Comparator.eq, 'finished'))
)
:add(Condition.Node(Condition.ColumnName('liquipediatiertype'), Condition.Comparator.eq, '!Points'))
local lpdbFilter = Condition.Tree(Condition.BooleanOperator.all):add{
Condition.Util.anyOf(Condition.ColumnName('status'), {'', 'finished'}),
Condition.Node(Condition.ColumnName('liquipediatiertype'), Condition.Comparator.neq, 'Points')
}

local allTournaments = Tournament.getAllTournaments(lpdbFilter, function(tournament)
return isWithinDateRange(tournament)
end)

---@param phase TournamentPhase
---@return fun(tournament: StandardTournament): boolean
local function filterByPhase(phase)
return function(tournament)
return tournament.phase == phase
Expand All @@ -91,7 +93,8 @@ function TournamentsTickerWidget:render()
---@param a StandardTournament
---@param b StandardTournament
---@param dateProperty 'endDate' | 'startDate'
---@param operator fun(a: StandardTournament, b: StandardTournament): boolean
---@param operator fun(a: integer, b: integer): boolean
---@return boolean?
local function sortByDateProperty(a, b, dateProperty, operator)
if not a[dateProperty] and not b[dateProperty] then
return nil
Expand All @@ -108,6 +111,9 @@ function TournamentsTickerWidget:render()
return nil
end

---@param a StandardTournament
---@param b StandardTournament
---@return boolean
local function sortByDate(a, b)
local endDateSort = sortByDateProperty(a, b, 'endDate', Operator.gt)
if endDateSort ~= nil then
Expand All @@ -120,6 +126,9 @@ function TournamentsTickerWidget:render()
return a.pageName < b.pageName
end

---@param a StandardTournament
---@param b StandardTournament
---@return boolean
local function sortByDateUpcoming(a, b)
local endDateSort = sortByDateProperty(a, b, 'startDate', Operator.gt)
if endDateSort ~= nil then
Expand Down
12 changes: 10 additions & 2 deletions lua/wikis/commons/Widget/Tournaments/Ticker/Sublist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ local HtmlWidgets = Lua.import('Module:Widget/Html/All')
local TournamentLabel = Lua.import('Module:Widget/Tournament/Label')
local FilterConfig = Lua.import('Module:FilterButtons/Config')

---@class TournamentsTickerSublistWidget: Widget
---@operator call(table): TournamentsTickerSublistWidget
---@class TournamentsTickerSublistWidgetProps
---@field title string
---@field tournaments StandardTournament[]
---@field displayGameIcons boolean

---@class TournamentsTickerSublistWidget: Widget
---@operator call(TournamentsTickerSublistWidgetProps): TournamentsTickerSublistWidget
---@field props TournamentsTickerSublistWidgetProps
local TournamentsTickerSublistWidget = Class.new(Widget)

---@return Widget?
Expand All @@ -26,6 +31,9 @@ function TournamentsTickerSublistWidget:render()
return
end

---@param tournament StandardTournament
---@param child Widget
---@return Widget
local createFilterWrapper = function(tournament, child)
return Array.reduce(FilterConfig.categories, function(prev, filterCategory)
local itemIsValid = filterCategory.itemIsValid or function(item) return true end
Expand Down
Loading