Index: fivestar.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fivestar/fivestar.module,v
retrieving revision 1.13.2.26
diff -u -p -r1.13.2.26 fivestar.module
--- fivestar.module	19 Apr 2008 05:59:17 -0000	1.13.2.26
+++ fivestar.module	11 Jul 2008 01:43:57 -0000
@@ -1592,3 +1592,22 @@ function fivestar_views_widget_handler($
 
   return drupal_get_form('fivestar_custom_widget', $values, $settings);
 }
+
+/**
+ * Implementation of hook_ranking().
+ *
+ * Provides a ranking factor based on average vote score.
+ *
+ */
+function fivestar_ranking() {
+  $ranking = array(
+    'fivestar_average_score' => array(
+      'title' => t('Fivestar Average Score'),
+      'score' => '((votingapi_cache.value / 100) * %f)',
+      'join' => "LEFT JOIN {votingapi_cache} votingapi_cache ON (votingapi_cache.content_id = i.sid AND votingapi_cache.function = 'average' AND votingapi_cache.content_type = 'node' AND votingapi_cache.tag = 'vote') ",
+      'score' => 'votingapi_cache.value',
+      'arguments'  => array(variable_get('node_fivestar_rating', '0')),
+    )
+  );
+  return $ranking;
+}
