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.