Page MenuHomePhabricator

API: Support user managed sort order
Closed, DeclinedPublic5 Estimated Story Points

Description

When editing a collection I should be able to do the following:
return this.postWithToken( 'watch', {

				action: 'editlist',
				id: 3,
				before: 'Foo',
				titles: [ 'Bar' ]

} );

This inserts the title 'Bar' in the collection with id 3 before the title 'Foo' which is in the collection.

  • If 'Foo' is not in the collection OR no before parameter is given it adds the new item to the end of the list and throws a warning
  • If 'Foo' is in the collection, it positions the new member(s) before the item 'Foo'

['X', 'Y', 'Foo'] => ['X', 'Y', 'Bar', 'Foo']
['X', 'Y'] => ['X', 'Y', 'Bar']

When I query the members of this collection, I can specify order: 'manual' which orders the collection by the

   {
				action: 'query',
				generator: 'listpages',
				glsporder: 'manual',
				glspid: 3,
				glsplimit: 50
			};

Event Timeline

Trellimport added a subscriber: Jdlrobson.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 27 2015, 1:17 AM
JKatzWMF moved this task from Needs triage to Product triage on the Gather board.Feb 27 2015, 1:24 AM
JKatzWMF moved this task from Product triage to Sub tasks on the Gather board.Mar 5 2015, 9:15 PM
Yurik added a subscriber: Yurik.Mar 11 2015, 11:31 PM

API already supports the notion of the item sort order (internally its a float, because that makes it much easier to insert items in the middle of the list)

Jdlrobson moved this task from Sub tasks to Some day on the Gather board.Apr 3 2015, 9:00 PM
Jdlrobson renamed this task from Every item in the list is given a number corresponding to its position in the list (ascending) to API: Support user managed sort order.Apr 21 2015, 10:38 PM
Jdlrobson assigned this task to Yurik.
Jdlrobson updated the task description. (Show Details)
Jdlrobson set Security to None.
Jdlrobson edited a custom field.
Jdlrobson moved this task from Some day to Should haves on the Gather board.
Jdlrobson updated the task description. (Show Details)
JKatzWMF moved this task from Should haves to Must haves on the Gather board.Apr 30 2015, 5:37 AM
Tgr updated the task description. (Show Details)Apr 30 2015, 10:17 PM
Yurik added a subscriber: Tgr.May 1 2015, 1:34 AM

@Tgr, also, take a look at how ordering is implemented in other api modules
(usually using "dir" param)

Tgr added a comment.May 6 2015, 2:43 PM

API already supports the notion of the item sort order (internally its a float, because that makes it much easier to insert items in the middle of the list)

The drawback is that manual ordering might break due to limited float precision. If insertion is done via order = ( prev + next ) / 2, then (given that MySQL float uses 23 bits for the fraction) order might get swapped after 23 rearrangement actions in the worst case (e.g. user repeatedly moving new items to the second position). I guess that's rare enough to ignore.

Yurik added a comment.May 6 2015, 2:44 PM

@Tgr, it is very easy to catch those, and if the difference between prev and next becomes less than some min value, update can simply change sorting value for a few more row. Not a big deal.

Tgr added a comment.May 6 2015, 9:00 PM

I'm not sure it's worth implementing both kinds of updates. If we implement a method to update gli_order for all rows, we can just use that all the time, adding another kind of insertion logic is just unnecessary complication.

Yurik added a comment.May 7 2015, 12:01 AM

I didn't say you should update all rows - you simply update a few surrounding rows, without the whole list, in the worst case. This is about efficiency - updating 5000 pages in someones list just because they decided to move a page into the beginning of the list is not acceptable perf wise - not only would you update the database for 5000 rows, you would also cause replication for all slave DB servers. Not good :)

Tgr added a comment.May 7 2015, 2:55 AM

How would you identify the rows which need updating? Seems hard to do without failing in some edge cases (not that that's necessarily a big problem).

Jdlrobson moved this task from Must haves to This Sprint on the Gather board.May 7 2015, 8:04 PM
Jdlrobson added a project: Gather Sprint Help!.
Jdlrobson edited a custom field.May 7 2015, 9:23 PM
Jdlrobson removed Yurik as the assignee of this task.May 11 2015, 6:02 PM
Jdlrobson moved this task from In Analysis to Ready for dev on the Gather Sprint Help! board.
Jdlrobson moved this task from Ready for dev to In Analysis on the Gather Sprint Help! board.
Jdlrobson moved this task from This Sprint to Must haves on the Gather board.May 27 2015, 6:36 PM
KLans_WMF triaged this task as Low priority.Sep 16 2015, 5:16 PM
MBinder_WMF closed this task as Declined.Jun 1 2016, 10:00 PM
MBinder_WMF added a subscriber: MBinder_WMF.

This task was declined as part of a batch-decline related to sunsetting the Gather project. Please ping (politely) if this task should be reopened. For more information, you can also see here: https://www.mediawiki.org/wiki/Extension:Gather