Skip to content

refactor(PortalStatistics): Standardized PortalStatistics to Table2 and Widget3 - #8043

Open
steve020607 wants to merge 11 commits into
mainfrom
steve23-patch2
Open

refactor(PortalStatistics): Standardized PortalStatistics to Table2 and Widget3#8043
steve020607 wants to merge 11 commits into
mainfrom
steve23-patch2

Conversation

@steve020607

@steve020607 steve020607 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

PortalStatistics is now still running at mw.html.create and wikitable, this pr changes it
with helped of Claude

How did you test this change?

dev
https://liquipedia.net/mobilelegends/User:Steve23/Testing_Page
https://liquipedia.net/mobilelegends/Portal:Statistics (put {{#vardefine:feature_dev|steve23}})

@steve020607 steve020607 self-assigned this Sep 2, 2026
@steve020607
steve020607 requested review from a team as code owners September 2, 2026 16:34
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
@steve020607

steve020607 commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

Might need more check on the annotiation from the master, since it's probably not right

@steve020607
steve020607 requested a review from hjpalpha September 3, 2026 11:13
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
if #args.showTierTypes then
for _, tierTypeValue in ipairs(args.showTierTypes) do
local _, tierTypeData = Tier.raw(nil, tierTypeValue)
local tierTypeCells = Array.map(args.showTierTypes, function(tierTypeValue)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need a nil check (or {} fallback) for the showTierType

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So wrap the args.showTierTypes with Logic.readBoolOrNil?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, the array map will error if it is nil, so you have to make sure it is not nil
readBoolOrNil would make it error always

@ElectricalBoy ElectricalBoy Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

args.showTierTypes = StatisticsPortal._isTableOrSplitOrDefault(args.showTierTypes, {})

---@param input string|table|nil
---@param default table?
---@return table
function StatisticsPortal._isTableOrSplitOrDefault(input, default)
if type(input) == 'table' then
return input
elseif String.isEmpty(input) then
return default or {}
end
return Array.parseCommaSeparatedString(input, ',')
end

never nil actually

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so do i add the or {} fallback or not?

Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
if #args.showTierTypes then
for _, tierTypeValue in ipairs(args.showTierTypes) do
local _, tierTypeData = Tier.raw(nil, tierTypeValue)
local tierTypeCells = Array.map(args.showTierTypes, function(tierTypeValue)

@ElectricalBoy ElectricalBoy Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

args.showTierTypes = StatisticsPortal._isTableOrSplitOrDefault(args.showTierTypes, {})

---@param input string|table|nil
---@param default table?
---@return table
function StatisticsPortal._isTableOrSplitOrDefault(input, default)
if type(input) == 'table' then
return input
elseif String.isEmpty(input) then
return default or {}
end
return Array.parseCommaSeparatedString(input, ',')
end

never nil actually

Comment on lines 785 to 787
local age = os.date('*t', os.difftime(TIMESTAMP, birthdate))
local yearAge = age.year - 1970
local dayAge = age.yday - 1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DateExt.calculateAge

@steve020607 steve020607 Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i seems don't know how to do it?
seems like i only get year, don't know how to show the day

Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
Comment thread lua/wikis/commons/PortalStatistics.lua Outdated
@steve020607 steve020607 changed the title refactor(PortalStatistics): refactor PortalStatistics to Table2 and Widget3 refactor(PortalStatistics): Standardized PortalStatistics to Table2 and Widget3 Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants