Page MenuHomePhabricator

order of value suggestions based on constraint doesn't follow order in constraint definition
Closed, ResolvedPublic5 Story Points

Description

Problem:
The one-of constraint provides a list of values that should be used with a property like "sex or gender". This list can be ordered by the editors based on a criteria like which values are most like to be used. "Male" and "Female" are listed first for example for "sex or gender".
When using the one-of constraint to make value suggestions in new statements this order is not respected and the values are suggested more or less randomly. This leads to "female" being one of the last suggestions for example. The suggestions should follow the order on the constraint definition.

Example:

BDD
GIVEN a property with a on-of constraint
WHEN creating a new statement with that property
THEN the suggestions are in the same order as they are on the constraint definition

Acceptance criteria:

  • When adding a new statement the order of the suggested values is the same as the order of the values in the definition of the one-of constraint

Details

Related Gerrit Patches:
mediawiki/extensions/Wikibase : masterImplement stable sort for entity selector

Event Timeline

Lydia_Pintscher triaged this task as Medium priority.Apr 10 2019, 8:54 AM
Lydia_Pintscher created this task.
Lydia_Pintscher moved this task from incoming to consider for next sprint on the Wikidata board.
Lydia_Pintscher moved this task from Incoming to Ready to estimate on the Wikidata-Campsite board.
WMDE-leszek set the point value for this task to 5.Apr 10 2019, 1:19 PM

I can’t reproduce this issue – I get correctly sorted suggestions in both Firefox and Chromium. Tested on the sandbox item and on Property:P21.

Weird. I tested it this morning and it didn't work. Let's look at it together tomorrow.

I think it might be browser-dependent – when I looked at the implementation, I noticed that we use Array.sort() to sort suggestions by their rating; this method implements a stable sort in some browsers (Firefox since forever, Chrome fairly recently), but not in others, so suggestions with the same rating (e. g. constraint suggestions) might get shuffled.

I guess we can either switch to a stable sort (library? implement ourselves?) or perhaps assign slightly different ratings for each constraint suggestion (1.000, 0.999, 0.998, etc.).

Change 503056 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Implement stable sort for entity selector

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

Okay, I was able to reproduce this on Chromium 65, which you can install on Ubuntu: download chromium-browser and chromium-codecs-ffmpeg from Trusty and install them via dpkg -i.

Change 503056 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Implement stable sort for entity selector

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

Can be tested on Beta now (P963).