Top Rated Author block
samuraitux - July 3, 2009 - 20:23
Hi guys I am trying to create a block that will contain the top rated author based on the plus1 and vote api. Here is the code that I am trying to use.
<?php
$users = db_query("SELECT COUNT(vote_id) AS count, users.name, users.uid FROM {votingapi_vote} LEFT JOIN {users} ON {votingapi_vote}.uid = {users}.uid WHERE {users}.uid != 0 GROUP BY {votingapi_vote}.uid ORDER BY count DESC LIMIT 10");
print "<ul>";
while ($user = db_fetch_object($users)) {
print "<li>" . l($user->name, drupal_get_path_alias("user/{$user->uid}")). " ($user->count)</li>";
}
print "</ul>";
?>I thought it worked but realized that it is crediting people commenting not giving the count to the poster of the blog. Can anyone help me with the query?

Just Tested and hot off the grill.
For anyone that is trying to do the same thing. Here is the code that I used to get it working.
<?php$users = db_query("SELECT COUNT(vote_id) AS count, users.name, users.uid FROM {votingapi_vote} LEFT JOIN {node} ON {votingapi_vote}.content_id = {node}.nid LEFT JOIN {users} ON {node}.uid = {users}.uid WHERE {users}.uid != 0 GROUP BY {users}.uid ORDER BY count DESC LIMIT 10");
print "<ul>";
while ($user = db_fetch_object($users)) {
print "<li>" . l($user->name, drupal_get_path_alias("user/{$user->uid}")). " ($user->count)</li>";
}
print "</ul>";
?>