Page MenuHomePhabricator

🍰 Simplify value format for some value types in statement data of REST API requests and responses
Closed, ResolvedPublic5 Estimated Story Points

Description

As a Wikibase data reuser I want to get statement data without unnecessary data so that I do not need to process data I do not need.

There are a few "fields" in the statement data of some value types that are either redundant or not used. Skipping those in the API requests and responses will reduce the load on API clients.

Value formats to adjust:

  • entity id values
    • turn them into a string containing the entity ID
  • "time" values
    • remove 'before'
    • remove 'after'
    • remove 'timezone'
  • "globe coordinate" values
    • remove 'altitude'

Expect the same adjusted format in request input.

Event Timeline

Silvan_WMDE renamed this task from Do not include currently not used fields in coordinate and time statement data in REST API requests and responses to Simplify value format for some value types in statement data of REST API requests and responses.Nov 9 2022, 12:30 PM
Silvan_WMDE updated the task description. (Show Details)
Silvan_WMDE set the point value for this task to 5.

Task breakdown notes

  • Serialization:
    • DataValue serialization is done in the PropertyValuePairSerializer
  • Deserialization:
    • DataValue deserialization is done by a DataValueDeserializer that's passed into the PropertyValuePairDeserializer
    • No need to handle time and globecoordinate differently as the simplification only removes optional/deprecated fields that the DataValueDeserializer doesn't need
    • wikibase-entityid needs to be converted from a string id (e.g. Q123) to an EntityIdValue to pass into PropertyValueSnak

Tasks

Simplify the value format in serializers - @Silvan_WMDE

  • Get the DataValue type from the Snak
  • If the DataValue type is one of wikibase-entityid, time, or globecoordinate:
    • alter the serialized format returned from DataValue::getArrayValue() according to the story description

T323702: 🍰 Simplify the value format in deserializers

  • if the DataValue type is wikibase-entityid:
    • use the EntityIdParser (that's already passed into PropertyValuePairDeserializer) to create an EntityId
    • create a new EntityIdValue from the EntityId
    • create the PropertyValueSnak from the property id and the EntityIdValue
    • return the PropertyValueSnak
Ollie.Shotton_WMDE renamed this task from Simplify value format for some value types in statement data of REST API requests and responses to 🍰 Simplify value format for some value types in statement data of REST API requests and responses.Nov 23 2022, 12:44 PM

@WMDE-leszek is it correct to assume that before, after and timezonemust be set to 0 when creating the TimeValue, since they are no longer provided in the request input?

@WMDE-leszek is it correct to assume that before, after and timezonemust be set to 0 when creating the TimeValue, since they are no longer provided in the request input?

I believe TimeValue `is an implementation concept so I shall not define how it should behave -- but I will answer a slightly different question: In places (e.g. persistence) where those now not-to-be-shown fields are actually stored, their values should use current "default".
This seems to be 0 for time's before, after and timezone, and null for coordinate's altitude