Roundup Tracker - Issues

Message5065

Author schlatterbeck
Recipients ber, r.david.murray, schlatterbeck, tekberg
Date 2014-04-03.14:16:48
Message-id <20140403141644.GA20704@runtux.com>
In-reply-to <1396458336.11.0.769250007551.issue2550834@psf.upfronthosting.co.za>
On Wed, Apr 02, 2014 at 05:05:36PM +0000, Tom Ekberg wrote:
> 
> Tom Ekberg added the comment:
>       '@sort': 'assignedto_multi,-activity',
>       '@group': 'target_date',
> ---------------
> This is what I changed it to which works fine:
> 
>       '@sort': '-activity',
>       '@group': 'target_date',
> 
> The only difference is @sort now only has one key. Previously it had
> assignedto, which was converted to assignedto_multi which a MultiLink
> version of assignedto.  I'm not sure why having only one sort key
> works, and two fails.

That clarifies it for me: In the non-working version you're sorting by a
Multilink (assignedto_multi) while for the second version no Multilink
is involved. As soon as multilinks are involved, sorting is done (at
least partially)* in python not in SQL.

The Reason: Multilink Sorting first sorts the individual multilinks for
each item by their order property (which is the labelprop if no
orderprop is explicitly defined or an 'order' attribute exists). And
*then* sorts the individual items by this list. AFAIK there is no way to
implement this in SQL although I'm willing to learn :-)

So in short: The python sorting for date properties should be fixed to
allow NULL values.

On the other hand: You really don't want to sort by Multilinks as the
sorting isn't done in SQL.

*) We sort *first* in SQL by all the properties right of the Multilink
and then we sort again in python on the multilink and all the properties
left of it. For the example (with multilink) above we would get the
following sort order:

'target_date', 'assignedto_multi', '-activity'

So we would sort (descending) by activity in SQL and then by target_date
and assignedto_multi in python (in one go). The sort order in Python is
stable** so we don't need to include the sorting by activity in python.

**) This means for items in the sort-list that compare equal we don't
change the order that they were in before sorting.

Ralf
-- 
Dr. Ralf Schlatterbeck                  Tel:   +43/2243/26465-16
Open Source Consulting                  www:   http://www.runtux.com
Reichergasse 131, A-3411 Weidling       email: office@runtux.com
allmenda.com member                     email: rsc@allmenda.com
History
Date User Action Args
2014-04-03 14:16:50schlatterbecksetrecipients: + schlatterbeck, ber, tekberg, r.david.murray
2014-04-03 14:16:50schlatterbecklinkissue2550834 messages
2014-04-03 14:16:48schlatterbeckcreate