How do I sort a view using the Drupal Fivestar average scores?
I am using Drupal 6.13, Views 6.x-2.6, Voting API 6.x-2.3, Fivestar 6.x-1.18.
I have a content type with a field of type Fivestar Rating. I have a view where my intention is to list all nodes with this content type, sorted in descending order, by average average rating. The view works in that it shows the correct information (the user votes with a vote and an overall average vote). But I canβt make it sort correctly for my life.
In the view, I have a link to "Node: Vote Results", Value Type = "Percentage", Vote Tag = "Normal", Aggregation Function: "Average".
I've tried a bunch of things, but what I expect is to add "Sort criteria" with "(Voting results) Voting results: Value" and top-down. When I do that, if I look at the sql query and I see "ORDER BY node_title ASC", which is clearly not the case. I expect to see "ORDER BY voteapi_cache_node_percent_vote_average_value DESC". Any pointers would be most appreciated.
Request here:
SELECT node.nid AS nid,
node.title AS node_title,
profile_values_profile_full_name.value AS profile_values_profile_full_name_value,
users.uid AS users_uid,
votingapi_vote_node_percent_vote_curuser.value AS votingapi_vote_node_percent_vote_curuser_value,
votingapi_cache_node_percent_vote_average.value AS votingapi_cache_node_percent_vote_average_value
FROM node node
LEFT JOIN votingapi_cache votingapi_cache_node_percent_vote_average ON node.nid = votingapi_cache_node_percent_vote_average.content_id AND (votingapi_cache_node_percent_vote_average.content_type = 'node' AND votingapi_cache_node_percent_vote_average.value_type = 'percent' AND votingapi_cache_node_percent_vote_average.tag = 'vote' AND votingapi_cache_node_percent_vote_average.function = 'average')
LEFT JOIN votingapi_vote votingapi_vote_node_percent_vote_curuser ON node.nid = votingapi_vote_node_percent_vote_curuser.content_id AND (votingapi_vote_node_percent_vote_curuser.content_type = 'node' AND votingapi_vote_node_percent_vote_curuser.value_type = 'percent' AND votingapi_vote_node_percent_vote_curuser.tag = 'vote' AND votingapi_vote_node_percent_vote_curuser.uid = '***CURRENT_USER***')
LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid
LEFT JOIN users users_node_revisions ON node_revisions.uid = users_node_revisions.uid
INNER JOIN users users ON node.uid = users.uid
LEFT JOIN profile_values profile_values_profile_full_name ON users.uid = profile_values_profile_full_name.uid AND profile_values_profile_full_name.fid = '5'
WHERE (node.type in ('passion_talk')) AND (node.status <> 0)
ORDER BY node_title ASC
source to share