Which field should be used in views to filter nodes with no votes?
BryanPflug - May 1, 2007 - 23:43
| Project: | Voting API |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I am trying to set up a view that provides nodes of a particular type that do NOT have any votes. I would have thought that a filter for VotingAPI percent rating value > 0 would do it, but it does not. I can filter nodes which DO have a rating (using the NodeAPI Average Vote >= 1 setting), but I haven't figured out how to do the complement (NodeAPI Average Vote < 1 doesn't do it!). Can you help? Thanks!

#1
try the following code in votingapi_views.inc in votingapi module.
replacing (line 212):
$query->add_where("%s %s %d", $field, $filter['operator'], $filter['value']);
with:
if (( $filter['operator'] == "<") || ( $filter['operator'] == "<=") ){
$query->add_where("$field is NULL OR %s %s %d", $field, $filter['operator'], $filter['value']);
} else {
$query->add_where("%s %s %d", $field, $filter['operator'], $filter['value']);
}
#2
Is this patch likely to find its way into the released code? I had to use it so that I could create a view that includes nodes with NO VOTES (i.e. just submitted, not voted on yet) and nodes with votes below an arbitrary threshold.