Project:Plus 1
Version:6.x-2.4
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

How would one query the database to list the top 5 voted?

Comments

#1

Views 2 will give you that. That was the whole point of Integrating the module with the Voting API: make it easier to create such lists.

#2

Having trouble with this too. I know I had this working properly once but now I can't get it to work with views 2. Everything is up to date.

In Views relationships I have Node Voting Results set to Valuetype = points, Vote tag = Vote and Aggregation Function = Count. The sorting criteria is using Voting Results API Function desc. I,ve tried all combinations of settings.

Is it something I am missing or there a bug?

Edit: Sorry I finally worked it out from the votingapi top_content view.

It wasn't very intuitive. Under "Voting API results: Value" it says "The value of an individual cast vote" and I didn't think that seemed to apply. I was wrong.

#3

I haven't had the need to install Views yet.

I would think using a module like views just to add a block with this result is quite heavy on the resources as compared to a direct database query wouldn't it?

With that in mind...

#4

Views is the way to go, I have the top items that have been voted on in the last 48 hours all through views, plus an RSS feed for it.

#5

Views is a lot of overhead and I don't want to use it if I don't have to. What I want can be accomplished with a database query and I thought that someone would have written one by now so I don't have to study the database to figure out how it works.

Seems that I will probably have to though.

#6

Here's the answer to your question but I suspect you really want a block or something like that.

SELECT n.nid, n.title, vc.value AS votes
FROM votingapi_cache vc
INNER JOIN node n ON n.nid=vc.content_id
WHERE vc.content_type = 'node'
AND vc.value_type = 'points'
AND vc.tag = 'vote'
AND vc.function = 'count'
ORDER BY votes DESC

I agree that Views is a lot of overhead for this.

#7

Category:support request» feature request

If I get commit access, you will have a block.

#8

Status:active» patch (to be ported)

#9

Status:patch (to be ported)» fixed

Committed to 6.x-2.x-dev.

#10

Status:fixed» closed (fixed)

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