Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Tried outputting and sorting the Total score but it merely outputs 0 and is therefore not sortable by this setting - I'm pretty sure this is a bug, as I don't seem to be doing anything incorrectly...
Comment | File | Size | Author |
---|---|---|---|
#37 | as_questions_high_level.png | 129.15 KB | Diogenes |
#37 | as_questions_relationship.png | 73.65 KB | Diogenes |
#37 | as_question_view.png | 117.27 KB | Diogenes |
#38 | vud_votingapi_vote_results_fix.patch | 762 bytes | Diogenes |
#38 | almosted_sorted_right.png | 77.89 KB | Diogenes |
Comments
Comment #1
jazzdrive3 CreditAttribution: jazzdrive3 commentedGetting the same error. I can't sort by votes at all with views. The value is always 0.
Using the plus 1 module with nodes. The tables votingapi_vote and votingapi_cache are getting updated correctly.
Comment #2
jazzdrive3 CreditAttribution: jazzdrive3 commentedHere's the view:
Comment #3
jazzdrive3 CreditAttribution: jazzdrive3 commentedDouble checking on this. Did something change in the latest release of views? Just trying to get this to the right people.
Comment #4
jazzdrive3 CreditAttribution: jazzdrive3 commentedAlso tested it with fivestar, and still the view is coming up with values of 0, even though there has been votes, and even though the vote are in the database.
Thanks!
Comment #5
jazzdrive3 CreditAttribution: jazzdrive3 commentedFigured the problem out, at least for me. The relationship was set up wrong. There are multiple "Vote: Results" relationships and I chose...poorly. ;)
Comment #6
Julia Trushina CreditAttribution: Julia Trushina commentedGot same kind of problem, not with filters or sorting, but with displaying TOTAL. Total votes of any nodes (even if they have correct AVG) are always 0.
Algorithm:
1. Add relationship Content:Vote results, set Aggregation function=Total score;
2. Add field Vote results: Value, select Relationship = name of #1 relationship; Add some another fields (i.e.title of node).
3. Save. Field #2 always shows 0.
Views 6.x-2.10, Voting API 6.x-2.x-dev (2010-04-23)
Comment #7
Julia Trushina CreditAttribution: Julia Trushina commentedSeems that votingapi module does not write SUM function to votingapi_cache table, because VIEWS result query has correct statement:
....LEFT JOIN votingapi_cache votingapi_cache_node_sum ON node.nid = votingapi_cache_node_sum.content_id AND (votingapi_cache_node_sum.content_type = 'node' AND votingapi_cache_node_sum.function = 'sum')
...
So, I have NO rows in votingapi_cache table with function=sum. Only 'average' and 'count'.
Comment #8
Julia Trushina CreditAttribution: Julia Trushina commentedP.S. Running cron and clearing cache does not help.
Comment #9
theo38 CreditAttribution: theo38 commentedDid this get fixed yet?
Comment #10
gausarts CreditAttribution: gausarts commentedSame results with vud. Filtering by vote results value greater than 0, but all 0 votes still display.
Subscribing. Thanks
Comment #11
gozigzag CreditAttribution: gozigzag commentedIt seems to be working ok for me. It is not trivial to setup. I am using vud (Vote Up/Down module). I have three relationships setup- for each one--- Value type: points, Vote tag: Normal vote. Aggregation function for each relationship: one using Positives, one using Negatives, and one using Number of votes. I can filter by number of votes greater than zero. And I can sort by both # of positives and # of negatives.
By the way, Negatives use negative number (doesn't count as in Integer the # of negatives). Keep in mind when sorting asc of desc.
Using Voting API 6.x-2.3, Vote Up/Down 6.x-2.0 and Views 6.x-2.11.
I initially struggled with it. So, thought I would post this hoping it could help others.
Comment #12
ShaneOnABike CreditAttribution: ShaneOnABike commented+1 has this been fixed as I can't seem to get a result other than 0 and am wondering if I am configuring this incorrectly?
Comment #13
p.brouwers CreditAttribution: p.brouwers commentedHave the same issue.
Relationship: Node Vote results
Label: Total score
Value type: percent
Vote tag: normal vote
Aggregation function: Total Score
Field: Vote results: Value
Appearance: Default appearance
Relationship: Total score
It outputs: 0
Comment #14
nizer CreditAttribution: nizer commentedsubscribing
Comment #15
nizer CreditAttribution: nizer commentedI happen to have the exact same problem: showing average vote results of nodes works perfect, the total amount of votes as well, but displaying the total score (points) simply doesn't work. As Julia Trushina states, the voting tables don't hold any of the 'total points' information.
As a temporary solution, I did manage to show the total points for every node not using the vote api, but by adding a custom php field (http://drupal.org/project/views_customfield). This custom field allows me to use php in a view and provides some parameters such as $data->nid which in my case, functions as the node id (since my filters only select nodes of a certain cck type). Using php, and with the nid supplied, it's fairly easy to calculate the total points yourself with a query on the votingapi_vote table.
Not an ideal sollution since the query is executed for every single row in the view result, but since there's no real bugfix yet, it might be a solution for some of you... The only problem I still have is that my view should be ordered desc based on this total points field, which can't be done, the value of the custom field is not available as a sort parameter.
Comment #16
neels CreditAttribution: neels commented+1 for fivestar
need this to work
Comment #17
upupax CreditAttribution: upupax commentedsubscribing
Comment #18
udvranto CreditAttribution: udvranto commentedsubscribing
Comment #19
udvranto CreditAttribution: udvranto commentedThe initial investigation suggests that the 'Value type' attribute is missing, causing the problem. I will post more later tonight.
Comment #20
udvranto CreditAttribution: udvranto commentedI upgrade to Views 3. Still no luck. I gave up after realizing the complexity of it.
Comment #21
udvranto CreditAttribution: udvranto commentedA little progress, but not there yet:
I was able to display the vote count. Views 3.x dev, VotingAPI 2.x dev.
Value type Percent, Tag normal vote, Aggregation Number of Votes.
It shows the number of votes in percent format. For example if 4 votes are casted, it will show 0.20 (20%, 100/4).
Comment #22
udvranto CreditAttribution: udvranto commentedFixed it! :D
The cache function was generating incorrect output. Fix the cache function as described below and vote a content to update the cache for that content (or update the vote cache thru cron). It will show the correct result.
I will post a patch shortly.
Line 487 and 490 must be changed.
Comment #23
udvranto CreditAttribution: udvranto commentedAdding the patch for 6.x-2.x.
Comment #24
udvranto CreditAttribution: udvranto commentedThe head version is completely different for Drupal 7. Not sure if it will need the patch. Leaving as it is.
Comment #25
dtecson CreditAttribution: dtecson commentedwhat about those value types that aren't points or percentage? For example, I am using the Mark module and I have that type selected.
Comment #26
udvranto CreditAttribution: udvranto commenteddtecson,
If it's working for you, just leave it like that. Otherwise you will need find out what change needs to be there in the cache function to fix your problem.
IMHO, the Voting API module developers are the right persons to comment and include/exclude the patch. From my point of view it needs to be fixed.
Comment #27
udvranto CreditAttribution: udvranto commentedIs it gonna get fixed any time soon? :(
Comment #28
udvranto CreditAttribution: udvranto commentedA side effect to this:
http://drupal.org/node/1054990#comment-4137120
Comment #29
YK85 CreditAttribution: YK85 commentedsubscribing
Comment #30
StevenWill CreditAttribution: StevenWill commentedsubscribing
Comment #31
heacu CreditAttribution: heacu commentedsubscribing
Comment #32
dgtlmoon CreditAttribution: dgtlmoon commentedI can confirm this also, the function column has no 'sum' data in votingapi cached results, so your Total Score wont ever work
Comment #33
dgtlmoon CreditAttribution: dgtlmoon commentedI've applied the patch above and can see new rows in my cache table
However SORT still does not work in views for this entry
I've added a relationship to my views
Top Voted: Configure Relationship Node: Vote results
[*] Require this relationship
Value type = points
Vote Tag = normal vote
Aggregate Function = Total Score
Additionally if i visit node/1169 the fivestar widget reports "No votes have been made"
Comment #34
udvranto CreditAttribution: udvranto commenteddgtlmoon,
Please apply this patch as well: http://drupal.org/node/1054990#comment-4137120
Comment #35
dgtlmoon CreditAttribution: dgtlmoon commentedYes I tried that change but still it did not make the fivestar work (see my comment on that thread)
Comment #36
konrad1811 CreditAttribution: konrad1811 commentedgot the same still not working
Comment #37
Diogenes CreditAttribution: Diogenes commentedI am bumping this issue, changing the version and the status. The last post here was 1 year, 35 weeks ago.
For context here, I have a multi-site win/unix dev platform. One of the sites is d7b.dev which is always a fresh install when things go wrong.
d7b.dev has just been updated to 7.23 today.
The voting_api and view modules each have their own Drupal git repositories and have each been refreshed today. A modified version of Vote Up/Down is being used to enumerate votes.
So I'm attempting to create a new view that presents the Questions with the most Votes. Here is a screen shot (first image) of the high level and then (second image) the Configure Relationship: Content: Vote results form.
Note that no filters are enabled yet the query yields 0 votes for every node. With no filters enabled, it should yield mutiple aggregraton results -- Number, Average, Total, Positives, Negatives -- but everything is zero (image 3).
Something is wrong here...
UPDATE - I forgot to mention that I saw this same behavior in D6 as well so I think the patch below might fix both. Hence the version change from 6 to 7.
Comment #38
Diogenes CreditAttribution: Diogenes commentedI thought you would never ask...
A patch has been attached...
I only figured this out by hacking the convoluted query generated by views/votingapi...
There are a few too many left joins here...
This is what I get after applying above patch (see image)
Although the numerical vote results show up, they are not sorted properly. Any question that has not been voted on (NULL) is at the bottom of the list, even after the stupid questions have been voted down.
I think this is because there is no way of applying a IFNULL(, 0) or COALESCE(, 0) function to an individual field in Views. I may be wrong.
COALESCE is a function name that must have been invented by a couple of software engineers after they had a few too many beers.
Whatever; it seems to be needed here. I digress.
Over to you Views...
Comment #39
suffering drupal CreditAttribution: suffering drupal commentedHello, much text here and little I understand.
Do I understand this is about the automatically generated view under /top-rated-points, which does NOT count the Plus 1 votes?
I see patches and configurations, and a jump from 3 years ago to 11 months ago, but nothing that looks like a real solution. Is the /top-rated-points view (still) not working and should I de-activate it in the menus or is there a way to give it some sense?
The Fivestar vote count under /top-rated-percent DOES seem to work (not sure if Plus 1 votes might be going there...)
I'm talking: D7.28, Plus 1 7.x-1.0-alpha2 and Fivestar 7.x-2.1
Thanks.
Comment #40
ckt.orange CreditAttribution: ckt.orange commented+1
Same issue here, can't get the results.
Keep showing 0, Views 3, Voting API 7.x-2.11, and Advanced Poll.
Comment #41
Nchase CreditAttribution: Nchase as a volunteer commentedSeems like this is still an issue...
Comment #42
blogers CreditAttribution: blogers commentedWhy no solution for this big bugg ? How get indivifdual value cast a vote to put a block how better vote a node ?
Comment #43
capysara CreditAttribution: capysara commentedThe module almost did all the things that I needed. I appreciate all the hard work that went into it! Unfortunately, I really needed the total to work and none of the patches I found did the trick for me. Since the module is in "no further development" and I don't need anything too sophisticated, I just went with the https://www.drupal.org/project/raty and https://www.drupal.org/project/starrating because they don't depend on the Voting API.
Comment #44
ron_s CreditAttribution: ron_s commentedI'm fairly sure this topic is a misunderstanding about how Voting API and Views works.
There is no need for a separate SUM column in Voting API. This option already exists in Views. Do the following:
1) Choose the view to edit.
2) Make sure you have the "Votes: Value" field included in your view.
3) Click the "Use aggregation" link in the Other section in the right column.
4) Choose "Yes" and save. After saving, all fields, filters, and sorts will show an "Aggregation settings" link next to them.
5) Click "Aggregation settings" for the "Votes: Value" field, and choose SUM.
This creates a view of all your results, with the votes summed together to display a total for each record.
Marking this issue as closed.