Download & Extend

Add update hook to update field values

Project:Fivestar
Version:7.x-2.0-alpha1
Component:Code
Category:bug report
Priority:minor
Assigned:Unassigned
Status:active

Issue Summary

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

#1

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

Thanks.

#2

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

#3

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.

#4

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

#5

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.

#6

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

Yea, Lets turn this into an update hook.

nobody click here