← Back to team overview

launchpad-dev team mailing list archive

Re: Displaying work items in the correct order

 

On 16/02/12 09:22, Guilherme Salgado wrote:
Hi folks,

The recently introduced SpecificationWorkItem table has a sequence
attribute that we'll use to track the position (on the work-items list)
of every work item. This is important so that we can present the list in
the same order it was when last changed.

The simplest way to implement that is probably by making it an actual
sequence of integers and
  - when an item is added to the end, use the next available integer
  - when an item is inserted on position N, use N as its sequence and
    shift all items with sequence>=N

That's obviously not ideal as it incurs some updates when the user
inserts an item not at the end of the list. (It doesn't sound like a
huge deal either as the sequence will be per-specification and I doubt
there are many specs with more than a couple dozen work items, but I'm
sure you guys will know better :)

The alternative I see would be to leave some gaps (with a fixed offset
of, say, 100) between the values used there (e.g. 0, 100, 200, 300, ...)
and do one of the following for added/moved items:
   - when inserted at the end, use the sequence of the last item plus
     the fixed offset
   - when inserted between two others items, use
     (sequence1+sequence2)/2 as the sequence of the new item

If we use a big enough offset it's unlikely that we'll ever run out of
space to insert new work items, but that doesn't feel very nice to me.
Of course we could also check before inserting and shift items if we
ever run out of space.

Is there any reason why you can't just use decimals instead of integers? That way you can insert new items without updates, or limiting places.

That way your sequence might be "1, 2, 3". And when you insert a new number you'll end up with something like "1, 2, 2.1, 3" etc. This is at least how a lot of interface sorting seems to be done. I'm not sure if other suggestions are better for caching/performance etc.


References