My site is going to be calculating vote cache incrementally - that is, rather than pulling all current votes (we're hoping for millions per node) we will instead pull the current cache values and add/remove counts and averages as needed on the fly. This means we want to suppress votingapi_votingapi_storage_standard_results() from querying for all of those records.

Currently, this function uses db_query, so there is no method that I'm aware of to prevent it from pulling all of the data; it will simply run.

The attached patch is my solution for switching over to db_select(). I added tags -"votingapi" and "standard_results" on both queries, and then "points", "percent" and "option" on their related queries. This allows me to grab exactly the query/ies I need to override.

This is my first patch submission, so please let me know if something is amiss or I need to re-categorize the issue. I did read the docs and tried my best to follow the guidelines!

CommentFileSizeAuthor
votingapi_recalculate_alterable.patch2.6 KBsuccinct

Comments

succinct’s picture

Here is my implementation of the hook, by the way:

function mymodule_query_votingapi_alter(QueryAlterableInterface $query) {
  if ($query->hasTag('standard_results') && $query->hasAnyTag('points', 'percent')) {
    // Alter query here.
  }
}
pifagor’s picture

Issue summary: View changes
Status: Active » Closed (outdated)