If a five star filed is added to a view it displays correct but if you use it for sorting it dose not work.
I could not figure out where the sort order comes from and how to change it.

Comments

ericduran’s picture

I think this is fixed in the latest dev version. Can you confirm?

Thanks.

zauberertz’s picture

Sorry no, the dev version does not fix it case this is the views query:

SELECT node.nid AS nid, node.title AS node_title, node.created AS node_created, 'node' AS field_data_field_vote_node_entity_type
FROM 
{node} node
LEFT JOIN {field_data_field_vote} field_data_field_vote ON node.nid = field_data_field_vote.entity_id AND (field_data_field_vote.entity_type = 'node' AND field_data_field_vote.deleted = '0')
WHERE (( (node.status = '1') AND (node.type IN  ('knowledgebase_article')) ))
ORDER BY field_data_field_vote.field_vote_rating DESC
LIMIT 25 OFFSET 0

And the field data table is empty

ericduran’s picture

Yea, that's because the fix when into the dev version. So unless the votes are done again after the dev version is running is going to be empty.

The simplest way of testing this is to place an actual vote now that you're running the dev version. THe data should start populating.

If this is not the case please let me know.

Thanks.

TSC_2010’s picture

I was having this issue as well. It is working properly for me.

zauberertz’s picture

The dev version fixes it for new entries, thanks.

Here are my SQL statements to solve it in my installation for the old data.This is might a good starting point for a additional update method.

INSERT INTO field_revision_field_vote(entity_type, bundle, deleted, entity_id, revision_id, language, delta, field_vote_rating, field_vote_target)
SELECT v.entity_type, n.type, 0, n.nid, n.vid, n.language, 0, v.value, NULL 
FROM votingapi_vote AS v
INNER JOIN node AS n ON v.entity_id = n.nid;
INSERT INTO field_data_field_vote(entity_type, bundle, deleted, entity_id, revision_id, language, delta, field_vote_rating, field_vote_target)
SELECT v.entity_type, n.type, 0, n.nid, n.vid, n.language, 0, v.value, NULL 
FROM votingapi_vote AS v
INNER JOIN node AS n ON v.entity_id = n.nid;

Thanks for the quick response.

ericduran’s picture

Title: Sorting in Views is not correct » Add update hook to update field values

Yea, Lets turn this into an update hook.

dbt102 credited dbt102.

dbt102’s picture

Issue summary: View changes
Status: Active » Fixed

Per comment #5 this got fixed in dev

Status: Fixed » Closed (fixed)

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