I have nodes where comments are allowed, users put rating in the comments, and then the averages is display in the node - typical stuff.

I created a views list of these results, using the table format, and I wanted to be able to sort by average rating.

The list shows correctly and the table cell title is clickable for 'asc' and 'desc.' However, when you click it, nothing happens - doesn't change.

Am I doing something wrong? Bug? The stars appear, but is the database column definition actually numeric that can be sorted on?

Comments

acarpio’s picture

I'm having the same issue and also wondering if I'm doing something wrong or it is a bug.

I'm using last dev releases for views, fivestar and all other modules required, developing localhost.

I will appreciate any help.

plach’s picture

Title: Fivestar in views results not sortable » Fivestar values not saved to the field storage when rating in view mode
Priority: Normal » Major
Status: Active » Needs review
StatusFileSize
new2.06 KB

Views is unable to sort by rating because when voting in view mode (through the ajax widget) the result is stored only in the votingapi tables and not into the field storage. The attached patch should fix this use case (existing votes will need to be re-entered).

plach’s picture

StatusFileSize
new2.05 KB

Cleaner patch

acarpio’s picture

This patch is working for me: views is sorting as expected, both Asc and Desc.

Thanks so much, plach.

Gastonia’s picture

thanks for the patch! will this be included into the next dev release?

ericduran’s picture

Status: Needs review » Needs work

This looks great. Can we add some test?

Also one minor thing :

+++ b/includes/fivestar.field.incundefined
@@ -145,6 +145,16 @@ function _fivestar_field_target($entity, $field, $instance, $item, $langcode) {
+  $langcode = LANGUAGE_NONE;

The language shouldn't be hard-coded into LANGUAGE_NONE.

ericduran’s picture

StatusFileSize
new2.05 KB

re-Uploading last patch to trigger test.

ericduran’s picture

Status: Needs work » Needs review
ericduran’s picture

@plach, lol I just saw the language code above the comment.

plach’s picture

So we just need tests here to have this fixed, right?

ericduran’s picture

Yea, test would be great! :)

ericduran’s picture

Status: Needs review » Fixed

Ok, I made some changes, but this is fixed now. -- http://drupalcode.org/project/fivestar.git/commit/b667347

Thanks everyone.

plach’s picture

Great, I'll see if I can find the time to write some tests anyway.

Status: Fixed » Closed (fixed)

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