After T380122, mw.title objects now have the pageAssessments property. These come as a Lua table indexed by number; however, this is an unexpected behavior different from the MediaWiki web service API, which indexes assessments by project name.
What happens?:
Run the following in the Wikipedia Lua debug console:
mw.logObject(mw.title.new("Apple").pageAssessments)
Returns:
table#1 { table#2 { ["class"] = "GA", ["importance"] = "High", ["name"] = "Agriculture", }, table#3 { ["class"] = "GA", ["importance"] = "Top", ["name"] = "Food and drink", }, table#4 { ["class"] = "GA", ["importance"] = "High", ["name"] = "Plants", }, table#5 { ["class"] = "GA", ["importance"] = "", ["name"] = "Project-independent assessment", }, }
How the MediaWiki web service API handles this:
The following API query:
action=query&format=json&prop=pageassessments&titles=Apple&formatversion=2&pasubprojects=1
Returns:
"title": "Apple", "pageassessments": { "Plants": { "class": "GA", "importance": "High" }, "Food and drink": { "class": "GA", "importance": "Top" }, "Agriculture": { "class": "GA", "importance": "High" }, "Project-independent assessment": { "class": "GA", "importance": "" } }
What should have happened instead?:
To allow Lua modules to programmatically retrieve specific assessments and meet feature parity with the web service API, the pageAssessments table should index by assessment, where:
mw.logObject(mw.title.new("Apple").pageAssessments)
Should return something like:
table#1 { ["Agriculture"] = { ["class"] = "GA", ["importance"] = "High", }, ["Food and drink"] = { ["class"] = "GA", ["importance"] = "Top", }, ["Plants"] = { ["class"] = "GA", ["importance"] = "High", }, ["Project-independent assessment"] = { ["class"] = "GA", ["importance"] = "", }, }