Page MenuHomePhabricator

Lua: Allow using labels in mw.wikibase.entity.formatPropertyValues
Closed, ResolvedPublic

Description

The getEntity() function that provides access to item data in lua returns a Lua table the reflects the structure of the data item as used by the API. This is very inconvenient for getting claims/statements and their values: In order to get all statements about property p123, one would have to loop over all claims and look at the property. Also, one would have to use the property ID.

A helper function getClaims(property) should be added to the entity structure, allowing the list of claims about a given property to be accessed by simply providing the property ID or (localized) property name.

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:19 AM
bzimport set Reference to bz46160.
bzimport added a subscriber: Unknown Object (MLST).

Can this be considered fixed as we now have:
entity:getProperties() and entity:formatPropertyValues( 'P123' ) ?

Yes, if formatPropertyValues also allows specifying the property by name instead of ID (I don't remember).

(In reply to Daniel Kinzler from comment #2)

Yes, if formatPropertyValues also allows specifying the property by name
instead of ID (I don't remember).

It doesn't (yet)...

Lydia_Pintscher removed a subscriber: Unknown Object (MLST).

For text values, a simple formatPropertyValues is enough. But for a scribunto module one could needs the month of a date to translate it in any language, or extract only the year. "27 december 2014" is not so easy. This could be easier with a fixed date-time format like -YYYYMMDD HH:MM:SS,nnn (minus/plus is for years before or from 1, and 0 could means "not defined"). Then an option to choose the type of format could be usefull. Another case is angle or geographic coordinates in radian / turn / grade / degree.

For text values, a simple formatPropertyValues is enough. But for a scribunto module one could needs the month of a date to translate it in any language, or extract only the year. "27 december 2014" is not so easy. This could be easier with a fixed date-time format like -YYYYMMDD HH:MM:SS,nnn (minus/plus is for years before or from 1, and 0 could means "not defined"). Then an option to choose the type of format could be usefull. Another case is angle or geographic coordinates in radian / turn / grade / degree.

Being able to change the way things get formatted would be another bug. This bug is only about accepting labels instead of property ids in formatPropertyValues. Please try to keep bugs about one topic.

Change 189415 had a related patch set uploaded (by Adrian Lang):
Consolidate duplicate PropertyParserFunction/Lua code

https://gerrit.wikimedia.org/r/189415

Patch-For-Review

Change 189415 merged by jenkins-bot:
Consolidate duplicate PropertyParserFunction/Lua code

https://gerrit.wikimedia.org/r/189415