function mymodule_votingapi_results_alter($cache, $content_type, $content_id){
  if ($content_type == 'node'){
    $cache['vote']['percent']['average'] = round($cache['vote']['percent']['average']/10)*10;
  }
}

Is this correct implementation of hook_results_alter? Will this work when the average calculation saved in to the vote cache table?

Please let me know

Thanks,
V

Comments

eaton’s picture

Status: Active » Closed (fixed)

Yep. Any information placed in that $cache variable will be inserted. The only difference between votingapi 1 and 2 is that you no longer get the full collection of every vote cast during the recalculation option. In other words, you need to do your own query against votingapi_votes if there is not already enough aggregate information in the cache array for you to extrapolate your new value.