When using votingapi values with views sorts, NULL values are placed at the bottom of the sort, but should rather be treated as 0 values. There are two possible solutions: (a) store zero value counts in the database (see #141439) or (b) query NULL's as 0's.

The attached patch implements the second option (b). This only changes the query used to create the views sort column. It doesn't change votingapi data storage or the calculation of values. I hope that by changing only the views sort query, that this patch will have more merit than one that changes the data structures and calculations, that would be necessary for option (a).

I've only tested it with the vote/points/sum combination, but hopefully it will work for others.

CommentFileSizeAuthor
sort.patch2.8 KBdouggreen

Comments

ingo86’s picture

Version: 5.x-1.x-dev » 6.x-2.3

i have the same problem, trying with views to sort nodes by votes (using sum as relationship) I always get -1 or +1 before 0.
I'm using 6.x 2.3 version.
This probably should be marked as critical, as a feature is not working fine.

JamieR’s picture

Subscribing. I'm having the same issue.

crea’s picture

Subs

chuckbar77’s picture

Is this still an issue? Thank you

eaton’s picture

Status: Needs review » Fixed

The latest version of VotingAPI for D6 and D7 allow admins to set up Views that use zero as a replacement for null values when sorting and filtering.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.